aboutsummaryrefslogtreecommitdiffstats
path: root/build/conf/go.conf
diff options
context:
space:
mode:
authorsnermolaev <snermolaev@yandex-team.com>2023-07-28 06:50:33 +0300
committersnermolaev <snermolaev@yandex-team.com>2023-07-28 06:50:33 +0300
commit10e54d8a4d3cb64929101a629dde889e91253a8c (patch)
tree6d551be3c13a1cf87da58521124150e393ef4617 /build/conf/go.conf
parent85ef4ee49c3edbb700d0ef903d01177bf9984018 (diff)
downloadydb-10e54d8a4d3cb64929101a629dde889e91253a8c.tar.gz
move go and perl stuff to their own confs; update java.conf
Diffstat (limited to 'build/conf/go.conf')
-rw-r--r--build/conf/go.conf946
1 files changed, 946 insertions, 0 deletions
diff --git a/build/conf/go.conf b/build/conf/go.conf
new file mode 100644
index 0000000000..ae5a1eb6e4
--- /dev/null
+++ b/build/conf/go.conf
@@ -0,0 +1,946 @@
+# tag:go-specific
+### @usage: COLLECT_GO_SWAGGER_FILES(Varname, Dir)
+###
+### Recursively collect files for swagger config creation
+macro COLLECT_GO_SWAGGER_FILES(Varname, Dir) {
+ _GLOB($Varname $Dir/**/*.go ${ARCADIA_ROOT}/go.mod)
+}
+
+# tag:go-specific
+GO_HOST_OS=unknown
+when ($HOST_OS_LINUX) {
+ GO_HOST_OS=linux
+}
+elsewhen ($HOST_OS_DARWIN) {
+ GO_HOST_OS=darwin
+}
+elsewhen($HOST_OS_WINDOWS) {
+ GO_HOST_OS=windows
+}
+
+# tag:go-specific
+GO_HOST_ARCH=unknown
+when ($HOST_ARCH_X86_64) {
+ GO_HOST_ARCH=amd64
+}
+elsewhen($HOST_ARCH_ARM64) {
+ GO_HOST_ARCH=arm64
+}
+
+# tag:go-specific
+GO_TARG_OS=unknown
+when ($OS_LINUX) {
+ GO_TARG_OS=linux
+}
+elsewhen ($OS_DARWIN) {
+ GO_TARG_OS=darwin
+}
+elsewhen ($OS_WINDOWS) {
+ GO_TARG_OS=windows
+}
+
+# tag:go-specific
+GO_TARG_ARCH=unknwon
+when ($ARCH_X86_64) {
+ GO_TARG_ARCH=amd64
+}
+elsewhen ($ARCH_I386) {
+ GO_TARG_ARCH=x86
+}
+elsewhen ($ARCH_ARM64) {
+ GO_TARG_ARCH=arm64
+}
+
+# tag:go-specific
+GO_HOST_TARG_PARAMS=++host-os $GO_HOST_OS ++host-arch $GO_HOST_ARCH ++targ-os $GO_TARG_OS ++targ-arch $GO_TARG_ARCH
+
+# tag:go-specific
+GOSTD_VERSION=1.20
+when ($GOSTD_VERSION == "1.20") {
+ GOSTD=contrib/go/_std_1.20/src
+}
+otherwise {
+ GOSTD=__unsupported_go_std_library_version_[$GOSTD_VERSION]__
+}
+
+# tag:go-specific
+GO_DEBUG_PATH_RELATIVE=no
+_GO_DEBUG_PATH__NO_UID__=
+_GO_COMPILE_SYMABIS_TRIMPATH__NO_UID__=
+
+# tag:go-specific
+_GO_BUILDMODE=
+_GO_IMPORT_PATH=${MODDIR}
+
+# tag:go-specific
+GO_VET=yolint
+GO_VET_TOOL=
+GO_VET_FLAGS=
+GO_VET_EXTRA_FLAGS=
+
+# tag:go-specific
+_GO_VET_ADD_CHECK=yes
+_GO_FMT_ADD_CHECK=yes
+_GO_YDX_FILE=
+
+# tag:go-specific
+_GO_CGO1_WRAPPER_FLAGS=--build-prefix=/-B --source-prefix=/-S
+_GO_LINK_EXE_EXT_CMD=
+
+# tag:go-specific
+GO_WITH_MUSL=
+
+# tag:go-specific
+GO_TOOLS_ROOT=${GO_TOOLS_RESOURCE_GLOBAL}
+GO_TEST_MINER=${tool:"tools/go_test_miner"}
+GO_TEST_IMPORT_PATH=
+
+# tag:go-specific
+GO_STD_LIB_PREFIX=${GOSTD}/
+GO_STD_CMD_PREFIX=${GOSTD}/cmd/
+GO_ARCADIA_PROJECT_PREFIX=a.yandex-team.ru/
+GO_CONTRIB_PROJECT_PREFIX=vendor/
+GO_SKIP_IMPORTS=unsafe C
+GO_VET_INFO_EXT=.vet.out
+GO_VET_REPORT_EXT=.vet.txt
+GO_VET_OUTPUT_INFO=${output;rootrel;hide;pre=${MODULE_PREFIX};suf=${MODULE_SUFFIX}${GO_VET_INFO_EXT}:REALPRJNAME}
+GO_VET_OUTPUT_REPORT=${output;rootrel;hide;pre=${MODULE_PREFIX};suf=${MODULE_SUFFIX}${GO_VET_REPORT_EXT}:REALPRJNAME}
+
+# tag:go-specific tag:codenav
+_GO_YNDEXER_EXT=.ydx.pb2
+GO_YNDEXER_OUTPUT=${output;pre=${MODULE_PREFIX};suf=${MODULE_SUFFIX}${_GO_YNDEXER_EXT}:REALPRJNAME}
+
+# tag:go-specific
+GO_PROJECT_PREFIXES=++std-lib-prefix $GO_STD_LIB_PREFIX ++arc-project-prefix $GO_ARCADIA_PROJECT_PREFIX
+
+# tag:go-specific
+_GO_FAKEID=${FAKEID}.${BUILD_TYPE}.${GOSTD_VERSION}.${GO_FAKEID}
+_CGO_FAKEID=${_GO_FAKEID}.${CPP_FAKEID}
+
+# tag:go-specific
+CGO2_CFLAGS_VALUE=
+CGO2_LDFLAGS_VALUE=
+
+# tag:go-specific
+GO_ASM_FLAGS_VALUE=
+### @usage: GO_ASM_FLAGS(flags)
+### Add the specified flags to the go asm compile command line.
+macro GO_ASM_FLAGS(Flags...) {
+ SET_APPEND(GO_ASM_FLAGS_VALUE $Flags)
+}
+
+# tag:go-specific
+GO_CGO1_FLAGS_VALUE=
+### @usage: GO_CGO1_FLAGS(flags)
+### Add the specified flags to the go cgo compile command line.
+macro GO_CGO1_FLAGS(Flags...) {
+ SET_APPEND(GO_CGO1_FLAGS_VALUE $Flags)
+}
+
+# tag:go-specific
+GO_CGO2_FLAGS_VALUE=
+### @usage: GO_CGO2_FLAGS(flags)
+### Add the specified flags to the go cgo compile command line.
+macro GO_CGO2_FLAGS(Flags...) {
+ SET_APPEND(GO_CGO2_FLAGS_VALUE $Flags)
+}
+
+# tag:go-specific
+GO_COMPILE_FLAGS_VALUE=$USER_GO_COMPILE_FLAGS
+### @usage: GO_COMPILE_FLAGS(flags)
+### Add the specified flags to the go compile command line.
+macro GO_COMPILE_FLAGS(Flags...) {
+ SET_APPEND(GO_COMPILE_FLAGS_VALUE $Flags)
+}
+
+# tag:go-specific
+GO_LINK_FLAGS_VALUE=$USER_GO_LINK_FLAGS
+### @usage: GO_LINK_FLAGS(flags)
+### Add the specified flags to the go link command line.
+macro GO_LINK_FLAGS(Flags...) {
+ SET_APPEND(GO_LINK_FLAGS_VALUE $Flags)
+}
+
+# tag:go-specific
+_GO_LANG_VERSION_VALUE=
+macro GOLANG_VERSION(Arg) {
+ SET(_GO_LANG_VERSION_VALUE $Arg)
+}
+
+# tag:go-specific
+_GO_TOOL_MODE=
+
+# tag:go-specific
+_GO_TOOL_COMMON_FLAGS=\
+ ++mode $_GO_TOOL_MODE \
+ $GO_PROJECT_PREFIXES \
+ ++goversion $GOSTD_VERSION \
+ ++lang $_GO_LANG_VERSION_VALUE \
+ ++source-root $ARCADIA_ROOT \
+ ++build-root $ARCADIA_BUILD_ROOT \
+ ++output-root $BINDIR \
+ ++toolchain-root $GO_TOOLS_ROOT \
+ $GO_HOST_TARG_PARAMS \
+ ++output $TARGET \
+ $GO_VET_OUTPUT \
+ $_GO_YDX_FILE \
+ $_GO_DEBUG_PATH__NO_UID__ \
+ ++srcs $AUTO_INPUT ${input:GO_FILES} \
+ ++asm-flags $GO_ASM_FLAGS_VALUE \
+ ++compile-flags $GO_COMPILE_FLAGS_VALUE \
+ ++link-flags $GO_LINK_FLAGS_VALUE \
+ ++cgo-srcs ${input:CGO_FILES} \
+ $_GO_EMBED_VALUE \
+ $_GO_BUILDMODE \
+ $GO_TOOLCHAIN_ENV
+
+# tag:go-specific
+macro _GO_GEN_COVER_GO(GO_FILE, GO_COVER_OUTPUT, VAR_ID) {
+ .CMD=${hide:_GO_FAKEID} $GO_TOOLS_ROOT/pkg/tool/${GO_HOST_OS}_${GO_HOST_ARCH}/cover -mode set -var $VAR_ID -o ${output;noext;suf=.cover.go:GO_COVER_OUTPUT} ${input:GO_FILE}
+}
+
+# tag:go-specific
+macro _GO_COMPILE_SYMABIS(FLAGS[], ASM_FILES...) {
+ .CMD=${hide:_CGO_FAKEID} $GO_TOOLS_ROOT/pkg/tool/${GO_HOST_OS}_${GO_HOST_ARCH}/asm $_GO_COMPILE_SYMABIS_TRIMPATH__NO_UID__ ${pre=-I :_C__INCLUDE} -I $GO_TOOLS_ROOT/pkg/include -D GOOS_${GO_TARG_OS} -D GOARCH_${GO_TARG_ARCH} $FLAGS $GO_ASM_FLAGS_VALUE -gensymabis -o ${output:"gen.symabis"} ${input:ASM_FILES} ${kv;hide:"p go"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
+ .ADDINCL=build/scripts/go_fake_include
+}
+
+# tag:go-specific
+macro _GO_COMPILE_CGO1(NAME, FLAGS[], FILES...) {
+ .CMD=${hide:_CGO_FAKEID} ${cwd:ARCADIA_ROOT} $YMAKE_PYTHON ${input:"build/scripts/cgo1_wrapper.py"} $_GO_CGO1_WRAPPER_FLAGS --build-root ${ARCADIA_BUILD_ROOT} --source-root ${ARCADIA_ROOT} --cgo1-files ${output;noext:FILES.cgo1.go} --cgo2-files ${output;noauto;noext:FILES.cgo2.c} -- ${GO_TOOLS_ROOT}/pkg/tool/${GO_HOST_OS}_${GO_HOST_ARCH}/cgo -objdir $BINDIR -importpath $NAME $GO_CGO1_FLAGS_VALUE $FLAGS -- $C_FLAGS_PLATFORM ${pre=-I:_C__INCLUDE} ${CGO_CFLAGS_VALUE} ${input:FILES} ${output;hide:"_cgo_export.h"} ${output;hide:"_cgo_export.c"} ${output;hide:"_cgo_gotypes.go"} ${output;noauto;hide:"_cgo_main.c"} ${output;noauto;hide:"_cgo_flags"} $GO_TOOLCHAIN_ENV ${kv;hide:"p go"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
+}
+
+# tag:go-specific
+macro _GO_COMPILE_CGO2(NAME, C_FILES[], S_FILES[], OBJ_FILES[], FILES...) {
+ .CMD=${hide:_CGO_FAKEID} $C_COMPILER $C_FLAGS_PLATFORM ${pre=-I:_C__INCLUDE} $CGO_CFLAGS_VALUE ${input;tobindir:"_cgo_main.c"} -c -o ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_main.c"} && $C_COMPILER $C_FLAGS_PLATFORM ${pre=-I:_C__INCLUDE} -o ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_"} $LDFLAGS $LDFLAGS_GLOBAL $CGO2_LDFLAGS_VALUE ${input;hide:"_cgo_export.h"} ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_main.c"} ${input;suf=${OBJECT_SUF}:"_cgo_export.c"} ${input;nopath;noext;suf=.cgo2.c${OBJECT_SUF}:FILES} ${input;suf=${OBJECT_SUF}:C_FILES} ${input;suf=.o:S_FILES} ${input:OBJ_FILES} $CGO_LDFLAGS_VALUE && ${GO_TOOLS_ROOT}/pkg/tool/${GO_HOST_OS}_${GO_HOST_ARCH}/cgo -dynpackage $NAME -dynimport ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_"} -dynout ${output:"_cgo_import.go"} -dynlinker $GO_CGO2_FLAGS_VALUE $GO_TOOLCHAIN_ENV ${kv;hide:"p go"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
+
+ _USE_LINKER()
+}
+
+GO_TOOL=$YMAKE_PYTHON3 ${input:"build/scripts/go_tool.py"} $_PROCESS_WHOLE_ARCHIVE_SCRIPT
+
+# tag:go-specific
+macro _GO_LINK_LIB_IMPL(CGO_FILES[], EXTRA_INPUTS[], EXTRA_TEXT_INPUTS[], GO_FILES...) {
+ .CMD=${hide:_GO_FAKEID} $GO_TOOL ${hide;input:EXTRA_INPUTS} ${hide;input;context=TEXT:EXTRA_TEXT_INPUTS} --ya-start-command-file $_GO_TOOL_COMMON_FLAGS ++peers ${rootrel;tags_in=local,GO|local,GO_PROTO|local,GO_FBS:PEERS} --ya-end-command-file ${kv;hide:"p GO"} ${kv;hide:"pc light-red"} ${kv;hide:"show_out"}
+}
+
+# tag:go-specific
+macro _GO_LINK_EXE_IMPL(CGO_FILES[], EXTRA_INPUTS[], EXTRA_TEXT_INPUTS[], GO_FILES...) {
+ .CMD=${hide:_GO_FAKEID} $GO_TOOL ${hide;input:EXTRA_INPUTS} ${hide;input;context=TEXT:EXTRA_TEXT_INPUTS} --ya-start-command-file $_GO_TOOL_COMMON_FLAGS ++vcs $VCS_GO $GO_WITH_MUSL $GO_EXTLD ++peers ${rootrel;tags_in=local,GO|local,GO_PROTO|local,GO_FBS:PEERS} ++non-local-peers ${rootrel;tags_in=GO|GO_PROTO|GO_FBS;tags_out=local:PEERS} ++cgo-peers ${VCS_C_OBJ_RR} ${rootrel;tags_out=GO|GO_PROTO|GO_FBS:PEERS} --ya-end-command-file ${kv;hide:"p LD"} ${kv;hide:"pc light-red"} ${kv;hide:"show_out"} $_GO_LINK_EXE_EXT_CMD
+}
+
+# tag:go-specific
+macro _GO_LINK_TEST_IMPL(CGO_FILES[], EXTRA_INPUTS[], EXTRA_TEXT_INPUTS[], GO_TEST_FILES[], GO_XTEST_FILES[], GO_FILES...) {
+ .CMD=${hide:_GO_FAKEID} $GO_TOOL ${hide;input:EXTRA_INPUTS} ${hide;input;context=TEXT:EXTRA_TEXT_INPUTS} --ya-start-command-file $_GO_TOOL_COMMON_FLAGS ++vcs $VCS_GO $GO_WITH_MUSL $GO_EXTLD ++test-miner $GO_TEST_MINER ++test-import-path $GO_TEST_IMPORT_PATH ++peers ${rootrel;tags_in=local,GO|local,GO_PROGRAM|local,GO_PROTO|local,GO_FBS:PEERS} ++non-local-peers ${rootrel;tags_in=GO|GO_PROTO|GO_FBS;tags_out=local:PEERS} ++cgo-peers ${VCS_C_OBJ_RR} ${rootrel;tags_out=GO|GO_PROGRAM|GO_PROTO|GO_FBS:PEERS} ++test_srcs ${input:GO_TEST_FILES} ++xtest_srcs ${input:GO_XTEST_FILES} ++cover_info $GO_COVER_INFO_VALUE ++skip-tests $_GO_SKIP_TEST_VALUE --ya-end-command-file ${kv;hide:"p GO"} ${kv;hide:"pc light-red"} ${kv;hide:"show_out"}
+}
+
+# tag:go-specific
+GO_LINK_LIB=$GENERATE_MF && $_GO_LINK_LIB_IMPL($_GO_SRCS_VALUE CGO_FILES $_CGO_SRCS_VALUE EXTRA_TEXT_INPUTS $_GO_EMBED_INPUTS)
+GO_LINK_EXE=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $GENERATE_VCS_GO_INFO_NODEP && $_GO_LINK_EXE_IMPL($_GO_SRCS_VALUE CGO_FILES $_CGO_SRCS_VALUE EXTRA_TEXT_INPUTS $_GO_EMBED_INPUTS)
+GO_LINK_TEST=$GENERATE_VCS_C_INFO_NODEP && $GENERATE_VCS_GO_INFO_NODEP && $_GO_LINK_TEST_IMPL($_GO_SRCS_VALUE CGO_FILES $_CGO_SRCS_VALUE EXTRA_TEXT_INPUTS $_GO_EMBED_INPUTS GO_TEST_FILES $_GO_TEST_SRCS_VALUE GO_XTEST_FILES $_GO_XTEST_SRCS_VALUE)
+GO_LINK_DLL=$GO_LINK_EXE && $COPY_CMD $BINDIR/_cgo_export.h ${output;pre=${MODULE_PREFIX};suf=.h:REALPRJNAME}
+
+# tag:go-specific
+CGO_ENABLED=yes
+when ($OS_WINDOWS == "yes" || $SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
+ CGO_ENABLED=no
+}
+elsewhen ($CGO_ENABLED == "yes") {
+ GO_LINK_FLAGS_VALUE+=-linkmode=external
+}
+
+# tag:go-specific
+GO_PACKAGE_VALUE=
+### @usage: GO_PACKAGE_NAME(Name)
+### Override name of a Go package.
+macro GO_PACKAGE_NAME(NAME) {
+ SET(GO_PACKAGE_VALUE $NAME)
+}
+
+# tag:go-specific tag:internal
+_GO_SRCS_VALUE=
+### @usage: _GO_SRCS(Files...) # internal
+### This macro shouldn't be used in ya.make files, use SRCS() instead.
+### This is internal macro collecting .go sources for processing within Go modules (GO_PROGRAM and GO_LIBRARY)
+macro _GO_SRCS(FILES...) {
+ GO_FAKE_OUTPUT($FILES)
+ SET_APPEND(_GO_SRCS_VALUE $FILES)
+}
+
+# tag:go-specific
+_GO_TEST_SRCS_VALUE=
+GO_HAS_INTERNAL_TESTS=no
+### @usage: GO_TEST_SRCS(Files...)
+### .go sources for internal tests of a module
+macro GO_TEST_SRCS(FILES...) {
+ GO_FAKE_OUTPUT($FILES)
+ _SET_FIRST_VALUE(GO_HAS_INTERNAL_TESTS ${pre=yes :FILES} ${GO_HAS_INTERNAL_TESTS})
+ SET_APPEND(_GO_TEST_SRCS_VALUE $FILES)
+}
+
+# tag:go-specific
+_GO_XTEST_SRCS_VALUE=
+GO_HAS_EXTERNAL_TESTS=no
+### @usage: GO_XTEST_SRCS(Files...)
+### .go sources for external tests of a module
+macro GO_XTEST_SRCS(FILES...) {
+ GO_FAKE_OUTPUT($FILES)
+ SET(GO_HAS_EXTERNAL_TESTS yes)
+ SET_APPEND(_GO_XTEST_SRCS_VALUE $FILES)
+}
+
+# tag:go-specific
+macro _GO_UNUSED_SRCS(FLAGS...) {
+ ENABLE(UNUSED_MACRO)
+}
+
+# tag:go-specific
+_CGO_SRCS_VALUE=
+### @usage: CGO_SRCS(Files...)
+### .go sources to be built with CGO
+macro CGO_SRCS(FILES...) {
+ SET_APPEND(_CGO_SRCS_VALUE $FILES)
+ PEERDIR(${GOSTD}/syscall)
+}
+
+# tag:go-specific
+GO_LDFLAGS_GLOBAL=
+### @usage: GO_LDFLAGS(Flags...)
+### Link flags for GO_PROGRAM linking from .go sources
+macro GO_LDFLAGS(FLAGS...) {
+ SET_APPEND(GO_LDFLAGS_GLOBAL $FLAGS)
+}
+
+# tag:go-specific
+CGO_CFLAGS_VALUE=
+### @usage: CGO_CFLAGS(Flags...)
+### Compiler flags specific to CGO compilation
+macro CGO_CFLAGS(FLAGS...) {
+ SET_APPEND(CGO_CFLAGS_VALUE $FLAGS)
+ CFLAGS($FLAGS)
+}
+
+# tag:go-specific
+CGO_LDFLAGS_VALUE=
+### @usage: CGO_LDFLAGS(Files...)
+### Linker flags specific to CGO linking
+macro CGO_LDFLAGS(FLAGS...) {
+ SET_APPEND(CGO_LDFLAGS_VALUE $FLAGS)
+ GO_LDFLAGS($FLAGS)
+}
+
+# tag:go-specific
+_GO_SKIP_TEST_VALUE=
+### @usage: GO_SKIP_TESTS(TestNames...)
+###
+### Define a set of tests that should not be run.
+### NB! Subtests are not taken into account!
+macro GO_SKIP_TESTS(TESTS...) {
+ SET_APPEND(_GO_SKIP_TEST_VALUE $TESTS)
+ RESTRICT_PATH(vendor MSG This macro is prohibited to be used outside the vendor/ directory)
+}
+
+# tag:go-specific tag:internal
+_GO_EMBED_VALUE=
+_GO_EMBED_INPUTS=
+### @usage: _GO_EMBED_PATTERN(PATTERN) # internal
+###
+### Define an embed pattern.
+macro _GO_EMBED_PATTERN(XTEST?"_xtest":"", PATTERN, IMPORT_PATH) {
+ SET(VAR_SALT1 $XTEST $PATTERN $IMPORT_PATH 1)
+ SET(_PATTERN_GLOB1 uniq_embed_${hash:VAR_SALT1})
+ _GLOB($_PATTERN_GLOB1 ${ARCADIA_ROOT}/${IMPORT_PATH}/${PATTERN}/**/* EXCLUDE ${ARCADIA_ROOT}/${IMPORT_PATH}/${PATTERN}/**/_* ${ARCADIA_ROOT}/${IMPORT_PATH}/${PATTERN}/**/.*)
+ SET(VAR_SALT2 $XTEST $PATTERN $IMPORT_PATH 2)
+ SET(_PATTERN_GLOB2 _uniq_embed_${hash:VAR_SALT2})
+ _GLOB($_PATTERN_GLOB2 ${ARCADIA_ROOT}/${IMPORT_PATH}/${PATTERN})
+ SET_APPEND(_GO_EMBED_VALUE ++embed$XTEST $PATTERN \$$_PATTERN_GLOB1 \$$_PATTERN_GLOB2)
+ SET_APPEND(_GO_EMBED_INPUTS \$$_PATTERN_GLOB1 \$$_PATTERN_GLOB2)
+}
+
+# tag:go-specific
+### @usage: GO_EMBED_PATTERN(PATTERN)
+###
+### Define an embed pattern.
+macro GO_EMBED_PATTERN(PATTERN) {
+ _GO_EMBED_PATTERN($PATTERN $_GO_IMPORT_PATH)
+}
+
+# tag:go-specific
+### @usage: GO_TEST_EMBED_PATTERN(PATTERN)
+###
+### Define an embed pattern for internal go tests.
+macro GO_TEST_EMBED_PATTERN(PATTERN) {
+ _GO_EMBED_PATTERN($PATTERN $_GO_IMPORT_PATH)
+}
+
+# tag:go-specific
+### @usage: GO_XTEST_EMBED_PATTERN(PATTERN)
+###
+### Define an embed pattern for external go tests.
+macro GO_XTEST_EMBED_PATTERN(PATTERN) {
+ _GO_EMBED_PATTERN(XTEST $PATTERN $_GO_IMPORT_PATH)
+}
+
+# tag:go-specific tag:internal
+### @usage: _GO_EMBED_DIR(PATTERN) # internal
+###
+### Define an embed directory DIR.
+macro _GO_EMBED_DIR(XTEST?"_xtest":"", DIR, IMPORT_PATH, ALL?"all:":"", EXCLUDES...) {
+ SET(VAR_SALT $XTEST $DIR $IMPORT_PATH)
+ SET(_PATTERN_GLOB uniq_embed_${hash:VAR_SALT})
+ _GLOB($_PATTERN_GLOB ${ARCADIA_ROOT}/${IMPORT_PATH}/${DIR}/**/* EXCLUDE ${pre=${ARCADIA_ROOT}/${IMPORT_PATH}/${DIR}/**/:EXCLUDES})
+ SET_APPEND(_GO_EMBED_VALUE ++embed$XTEST $ALL$DIR \$$_PATTERN_GLOB)
+ SET_APPEND(_GO_EMBED_INPUTS \$$_PATTERN_GLOB)
+}
+
+# tag:go-specific
+### @usage: GO_EMBED_DIR(DIR)
+###
+### Define an embed directory DIR.
+macro GO_EMBED_DIR(ALL?"ALL":"_* .*", DIR) {
+ _GO_EMBED_DIR($DIR $_GO_IMPORT_PATH ${ALL})
+}
+
+# tag:go-specific
+### @usage: GO_EMBED_TEST_DIR(DIR)
+###
+### Define an embed directory DIR for internal go tests.
+macro GO_EMBED_TEST_DIR(ALL?"ALL":"_* .*", DIR) {
+ _GO_EMBED_DIR($DIR $_GO_IMPORT_PATH ${ALL})
+}
+
+# tag:go-specific
+### @usage: GO_EMBED_XTEST_DIR(DIR)
+###
+### Define an embed directory DIR for external go tests.
+macro GO_EMBED_XTEST_DIR(ALL?"ALL":"_* .*", DIR) {
+ _GO_EMBED_DIR(XTEST $DIR $_GO_IMPORT_PATH ${ALL})
+}
+
+# tag:go-specific
+_GO_TOOLCHAIN_ENV_GOARCH=unknown
+when ($ARCH_ARM64) {
+ _GO_TOOLCHAIN_ENV_GOARCH=${env:"GOARCH=arm64"}
+}
+elsewhen ($ARCH_X86_64) {
+ _GO_TOOLCHAIN_ENV_GOARCH=${env:"GOARCH=amd64"}
+}
+
+# tag:go-specific
+_GO_TOOLCHAIN_ENV_GOOS=unknown
+when ($OS_DARWIN) {
+ _GO_TOOLCHAIN_ENV_GOOS=${env:"GOOS=darwin"}
+}
+elsewhen ($OS_LINUX) {
+ _GO_TOOLCHAIN_ENV_GOOS=${env:"GOOS=linux"}
+}
+elsewhen ($OS_WINDOWS) {
+ _GO_TOOLCHAIN_ENV_GOOS=${env:"GOOS=windows"}
+}
+_GO_TOOLCHAIN_ENV_PATH=
+
+# tag:go-specific
+GO_TOOLCHAIN_ENV=$TOOLCHAIN_ENV $_GO_TOOLCHAIN_ENV_GOARCH $_GO_TOOLCHAIN_ENV_GOOS $_GO_TOOLCHAIN_ENV_PATH
+
+# tag:go-specific
+_GO_GRPC_WELLKNOWN=\
+ vendor/google.golang.org/grpc \
+ vendor/google.golang.org/grpc \
+ vendor/google.golang.org/grpc/codes \
+ vendor/google.golang.org/grpc/grpclog \
+ vendor/google.golang.org/grpc/status
+
+# tag:go-specific
+macro _GO_GRPC() {
+ SET(GO_PROTO_GEN_PLUGINS plugins=grpc)
+ SET(GO_PROTO_GRPC_OPTS \$GO_PROTO_GRPC_OPTS_V2)
+ SET(GO_PROTO_GRPC_OUTS \$GO_PROTO_GRPC_OUTS_V2)
+ PEERDIR(${GOSTD}/context ${_GO_GRPC_WELLKNOWN})
+}
+
+# tag:go-specific
+### @usage: GO_GRPC_GATEWAY_SRCS()
+###
+### Use of grpc-gateway plugin (Supported for Go only).
+macro GO_GRPC_GATEWAY_SRCS(FILE...) {
+ ENABLE(UNUSED_MACRO)
+}
+
+# tag:go-specific
+### @usage: GO_GRPC_GATEWAY_SWAGGER_SRCS()
+###
+### Use of grpc-gateway plugin w/ swagger emission (Supported for Go only).
+macro GO_GRPC_GATEWAY_SWAGGER_SRCS(FILE...) {
+ PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options)
+}
+
+# tag:go-specific
+_GO_PROTO_GRPC_GATEWAY_OPTS=
+_GO_PROTO_GRPC_GATEWAY_OUTS=
+
+# tag:go-specific
+macro _GO_GRPC_GATEWAY_SRCS_IMPL(Files...) {
+ foreach (File : $Files) {
+ [.proto]=$_GO_PROTO_CMD_IMPL($File $_GO_PROTO_GRPC_GATEWAY_OPTS $_GO_PROTO_GRPC_GATEWAY_OUTS)
+ }
+
+ PEERDIR(${GOSTD}/context ${GOSTD}/io ${GOSTD}/net/http)
+ PEERDIR(vendor/github.com/golang/protobuf/descriptor)
+ PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/runtime)
+ PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/utilities)
+ PEERDIR(vendor/google.golang.org/grpc/metadata)
+}
+
+# tag:go-specific
+macro _SETUP_GO_GRPC_GATEWAY() {
+ SET(_GO_PROTO_GRPC_GATEWAY_OPTS $_PROTO_PLUGIN_ARGS_BASE(go_grpc_gw vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway allow_repeated_fields_in_body=true))
+ SET(_GO_PROTO_GRPC_GATEWAY_OUTS \${output;hide;norel;nopath;noext;suf=.pb.gw.go:File})
+}
+
+# tag:go-specific
+macro _GO_GRPC_GATEWAY_SRCS(Files...) {
+ _SETUP_GO_GRPC_GATEWAY()
+ _GO_GRPC_GATEWAY_SRCS_IMPL($Files)
+}
+
+# tag:go-specific
+macro _GO_GRPC_GATEWAY_SWAGGER_SRCS(Files...) {
+ _SETUP_GO_GRPC_GATEWAY()
+ SET_APPEND(_GO_PROTO_GRPC_GATEWAY_OPTS $_PROTO_PLUGIN_ARGS_BASE(swagger vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger logtostderr=true allow_repeated_fields_in_body=true))
+ SET_APPEND(_GO_PROTO_GRPC_GATEWAY_OUTS \${output;hide;norel;noauto;nopath;noext;suf=.swagger.json:File})
+
+ _GO_GRPC_GATEWAY_SRCS_IMPL($Files)
+ PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options)
+}
+
+#tag:go-specific
+### @usage: GO_GRPC_GATEWAY_V2_OPENAPI_SRCS(Files...)
+###
+### Use of grpc-gateway plugin w/ openapi v2 emission (Supported for Go only).
+macro GO_GRPC_GATEWAY_V2_OPENAPI_SRCS(NO_JSON_NAMES_FOR_FIELDS?"":"", Files...) {
+ PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options)
+}
+
+macro _GO_GRPC_GATEWAY_V2_OPENAPI_SRCS(NO_JSON_NAMES_FOR_FIELDS?"json_names_for_fields=false":"", Files...) {
+ _SETUP_GO_GRPC_GATEWAY_V2()
+
+ SET_APPEND(_GO_PROTO_GRPC_GATEWAY_V2_OPTS $_PROTO_PLUGIN_ARGS_BASE(openapiv2 vendor/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 $NO_JSON_NAMES_FOR_FIELDS logtostderr=true))
+ SET_APPEND(_GO_PROTO_GRPC_GATEWAY_V2_OPTS \${output;hide;norel;noauto;nopath;noext;suf=.swagger.json:File})
+
+ _GO_GRPC_GATEWAY_V2_SRCS_IMPL($Files)
+ PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options)
+}
+
+# tag:go-specific
+### @usage: GO_GRPC_GATEWAY_V2_SRCS()
+###
+### Use of grpc-gateway plugin (Supported for Go only).
+macro GO_GRPC_GATEWAY_V2_SRCS(FILE...) {
+ ENABLE(UNUSED_MACRO)
+}
+
+# tag:go-specific
+_GO_PROTO_GRPC_GATEWAY_V2_OPTS=
+_GO_PROTO_GRPC_GATEWAY_V2_OUTS=
+
+# tag:go-specific
+macro _GO_GRPC_GATEWAY_V2_SRCS_IMPL(Files...) {
+ foreach (File : $Files) {
+ [.proto]=$_GO_PROTO_CMD_IMPL($File $_GO_PROTO_GRPC_GATEWAY_V2_OPTS $_GO_PROTO_GRPC_GATEWAY_V2_OUTS)
+ }
+
+ PEERDIR(${GOSTD}/context ${GOSTD}/io ${GOSTD}/net/http)
+ PEERDIR(vendor/github.com/golang/protobuf/descriptor)
+ PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime)
+ PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/v2/utilities)
+ PEERDIR(vendor/google.golang.org/grpc/metadata)
+ PEERDIR(vendor/google.golang.org/protobuf/proto)
+}
+
+# tag:go-specific
+macro _SETUP_GO_GRPC_GATEWAY_V2() {
+ SET(_GO_PROTO_GRPC_GATEWAY_V2_OPTS $_PROTO_PLUGIN_ARGS_BASE(go_grpc_gw vendor/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway allow_repeated_fields_in_body=true))
+ SET(_GO_PROTO_GRPC_GATEWAY_V2_OUTS \${output;hide;norel;nopath;noext;suf=.pb.gw.go:File})
+}
+
+# tag:go-specific
+macro _GO_GRPC_GATEWAY_V2_SRCS(Files...) {
+ _SETUP_GO_GRPC_GATEWAY_V2()
+ _GO_GRPC_GATEWAY_V2_SRCS_IMPL($Files)
+}
+
+# tag:go-specific
+when ($MUSL == "yes") {
+ _GO_DEFAULT_ALLOCATOR=LF
+}
+otherwise {
+ _GO_DEFAULT_ALLOCATOR=FAKE
+}
+
+# tag:go-specific tag:internal
+### @usage _GO_BASE_UNIT # internal
+###
+### The base module of all golang modules. Defines common properties, dependencies and rules for go build.
+module _GO_BASE_UNIT: _BASE_UNIT {
+ .EXTS=.go .gosrc .o .obj .a .symabis .mf
+ .CMD=TOUCH_UNIT
+ .NODE_TYPE=Bundle
+ .GLOBAL=GO_LDFLAGS
+ .PEERDIR_POLICY=as_build_from
+ .ALIASES=SRCS=_GO_SRCS RESOURCE=_GO_RESOURCE GO_TEST_SRCS=_GO_UNUSED_SRCS GO_XTEST_SRCS=_GO_UNUSED_SRCS GRPC=_GO_GRPC GO_GRPC_GATEWAY_SRCS=_GO_GRPC_GATEWAY_SRCS GO_GRPC_GATEWAY_SWAGGER_SRCS=_GO_GRPC_GATEWAY_SWAGGER_SRCS CFLAGS=CGO_CFLAGS GO_TEST_EMBED_PATTERN=_GO_UNUSED_SRCS GO_XTEST_EMBED_PATTERN=_GO_UNUSED_SRCS GO_TEST_EMBED_DIR=_GO_UNUSED_SRCS GO_XTEST_EMBED_DIR=_GO_UNUSED_SRCS GO_GRPC_GATEWAY_V2_SRCS=_GO_GRPC_GATEWAY_V2_SRCS GO_GRPC_GATEWAY_V2_OPENAPI_SRCS=_GO_GRPC_GATEWAY_V2_OPENAPI_SRCS
+ .ALLOWED=GO_PROTO_PLUGIN USE_CXX USE_UTIL RESOURCE_FILES
+ .IGNORED=GO_SKIP_TESTS USE_SKIFF
+ .RESTRICTED=TEST_SRCS
+ .DEFAULT_NAME_GENERATOR=UseDirNameOrSetGoPackage
+
+ ENABLE(_GO_MODULE)
+ SET(MODULE_TAG GO)
+ SET(PEERDIR_TAGS GO GO_PROTO GO_FBS __EMPTY__)
+ DEFAULT(_GO_VET_TOOL)
+ DEFAULT(_GO_VET_FLAGS)
+ DEFAULT(_GO_VET_EXTS)
+ DEFAULT(_GO_SONAME)
+
+ NO_RUNTIME()
+
+ SET(COVERAGE_FLAGS)
+ SET(EXTRA_OUTPUT)
+ SET(MODULE_LANG GO)
+ ENABLE(FORCE_CONSISTENT_DEBUG)
+
+ PEERDIR(build/external_resources/go_tools)
+
+ GO_PROTO_GRPC_OPTS_V2=--plugin=protoc-gen-go-grpc=${tool:_TOOL_PROTOC_GEN_GO_GRPC_V2} --go-grpc_out=${ARCADIA_BUILD_ROOT}/$PROTO_NAMESPACE
+ GO_PROTO_GRPC_OUTS_V2=${output;norel;nopath;noext;suf=_grpc.pb.go:File}
+ select ($GO_PROTO_V2) {
+ "yes" | "on" ? {
+ GO_PROTO_OUTS+=${output;hide;norel;nopath;noext;suf=.pb.go:File}
+ GO_PROTO_OPTS+=--plugin=protoc-gen-go=${tool:_TOOL_PROTOC_GEN_GO_V2} --go_out=${ARCADIA_BUILD_ROOT}/$PROTO_NAMESPACE
+ _GO_PROTO_CHECK_OUTPUT=--check $GO_PROTO_GRPC_OUTS_V2
+ GO_PROTO_OPTS+=$GO_PROTO_GRPC_OPTS
+ }
+ default ? {
+ GO_PROTO_OUTS+=${output;hide;norel;nopath;noext;suf=.pb.go:File}
+ GO_PROTO_OPTS+=--plugin=protoc-gen-go=${tool:_TOOL_PROTOC_GEN_GO} --go_out=$GO_PROTO_GEN_PLUGINS:${ARCADIA_BUILD_ROOT}/$PROTO_NAMESPACE
+ }
+ }
+
+ when ($COMPILER_PLATFORM && $NEED_PLATFORM_PEERDIRS == "yes") {
+ PEERDIR+=$COMPILER_PLATFORM
+ }
+
+ when ($CLANG == "yes" || $GCC == "yes") {
+ CGO_CFLAGS_VALUE += -w -pthread -fpic
+ CGO2_CFLAGS_VALUE += -Wno-unused-variable
+ }
+
+ select ($GO_VET) {
+ "yes" | "on" ? {
+ _GO_VET=yes
+ _GO_VET_FLAGS+=-cgocall=false
+ }
+ "yndexer" ? {
+ _GO_VET=yes
+ PEERDIR+=build/external_resources/goyndexer
+ _GO_VET_TOOL=${GOYNDEXER_RESOURCE_GLOBAL}/goyndexer
+ _GO_YDX_FILE=++ydx-file ${_GO_YNDEXER_EXT}
+ _GO_VET_FLAGS=-indexer.arc ${ARCADIA_ROOT} -indexer.indexfile ${GO_YNDEXER_OUTPUT} -indexer.loglevel info
+ _GO_FMT_ADD_CHECK=no
+ _GO_VET_ADD_CHECK=no
+ GO_VET_INFO_EXT=.ydx.out
+ GO_VET_REPORT_EXT=.ydx.txt
+ _GO_VET_EXTS=++vet-info-ext .ydx.out ++vet-report-ext .ydx.txt
+ _GO_CGO1_WRAPPER_FLAGS=--build-prefix=__ARCADIA_BUILD_ROOT_PREFIX__ --source-prefix=__ARCADIA_SOURCE_ROOT_PREFIX__
+ }
+ "yolint" ? {
+ _GO_VET=yes
+ PEERDIR+=build/external_resources/yolint
+ _GO_VET_TOOL=${YOLINT_RESOURCE_GLOBAL}/yolint
+ _GO_VET_FLAGS=-migration.config=${input:"${ARCADIA_ROOT}/build/rules/go/migrations.yaml"} -scopelint.config=${input:"${ARCADIA_ROOT}/build/rules/go/extended_lint.yaml"}
+ }
+ "local" ? {
+ _GO_VET=yes
+ _GO_VET_FLAGS=
+ }
+ default ? {
+ _GO_VET=no
+ _GO_VET_FLAGS=
+ }
+ }
+ SET(_GO_VET $_GO_VET)
+
+ when ($GO_VET_TOOL == "") {
+ _GO_VET_TOOL_REAL=$_GO_VET_TOOL
+ }
+ otherwise {
+ _GO_VET_TOOL_REAL=$GO_VET_TOOL
+ }
+
+ when ($GO_VET_FLAGS == "") {
+ _GO_VET_FLAGS_REAL=$_GO_VET_FLAGS
+ }
+ otherwise {
+ _GO_VET_FLAGS_REAL=$GO_VET_FLAGS
+ }
+
+ when ($_GO_VET == "yes" && $NO_GO_VET != "yes") {
+ GO_VET_OUTPUT=++vet $_GO_VET_TOOL_REAL ++vet-flags $_GO_VET_FLAGS_REAL $GO_VET_EXTRA_FLAGS $GO_VET_OUTPUT_INFO $GO_VET_OUTPUT_REPORT $_GO_VET_EXTS
+ }
+ otherwise {
+ GO_VET_OUTPUT=
+ _GO_VET_ADD_CHECK=no
+ }
+
+ when ($GO_DEBUG_PATH_RELATIVE == "yes") {
+ _GO_DEBUG_PATH__NO_UID__=++debug-root-map source=;build=;tools= ++tools-root $(TOOL_ROOT)
+ _GO_COMPILE_SYMABIS_TRIMPATH__NO_UID__=-trimpath $ARCADIA_ROOT=>;$ARCADIA_BUILD_ROOT=>;$(TOOL_ROOT)=>
+ }
+ otherwise {
+ _GO_DEBUG_PATH__NO_UID__=++debug-root-map source=/-S;build=/-B;tools=/-T ++tools-root $(TOOL_ROOT)
+ _GO_COMPILE_SYMABIS_TRIMPATH__NO_UID__=-trimpath $ARCADIA_ROOT=>/-S;$ARCADIA_BUILD_ROOT=>/-B;$(TOOL_ROOT)=>/-T
+ }
+
+ _GO_PROCESS_SRCS()
+
+ when ($CLANG == "yes") {
+ _GO_EXTLD=clang
+ GO_TOOLCHAIN_ENV += ${env:"CC=clang"}
+ }
+ otherwise {
+ _GO_EXTLD=gcc
+ GO_TOOLCHAIN_ENV += ${env:"CC=gcc"}
+ }
+
+ when ($OS_DARWIN) {
+ PEERDIR+=build/external_resources/go_fake_xcrun
+ GO_EXTLD = ++extld $_GO_EXTLD ++extldflags $_GO_SONAME $LD_SDK_VERSION -undefined dynamic_lookup $C_FLAGS_PLATFORM --sysroot=$MACOS_SDK_RESOURCE_GLOBAL --start-wa ${rootrel;ext=.a:SRCS_GLOBAL} --end-wa ${rootrel;ext=.o:SRCS_GLOBAL} --cgo-peers $LDFLAGS $LDFLAGS_GLOBAL $OBJADDE $OBJADDE_LIB $GO_LDFLAGS_GLOBAL $C_LIBRARY_PATH $C_SYSTEM_LIBRARIES_INTERCEPT $C_SYSTEM_LIBRARIES $STRIP_FLAG
+ CGO2_LDFLAGS_VALUE += $LD_SDK_VERSION -undefined dynamic_lookup -nodefaultlibs -lc
+ }
+ elsewhen ($OS_LINUX) {
+ GO_EXTLD = ++extld $_GO_EXTLD ++extldflags $_GO_SONAME $C_FLAGS_PLATFORM --sysroot=$OS_SDK_ROOT_RESOURCE_GLOBAL -Wl,--whole-archive ${rootrel;ext=.a:SRCS_GLOBAL} -Wl,--no-whole-archive ${rootrel;ext=.o:SRCS_GLOBAL} --cgo-peers $LDFLAGS $LDFLAGS_GLOBAL $OBJADDE $OBJADDE_LIB $GO_LDFLAGS_GLOBAL $C_LIBRARY_PATH $C_SYSTEM_LIBRARIES_INTERCEPT $C_SYSTEM_LIBRARIES $STRIP_FLAG
+ CGO2_LDFLAGS_VALUE += -Wl,--unresolved-symbols=ignore-all -nodefaultlibs -lc
+ }
+ otherwise {
+ GO_EXTLD = ++extld $_GO_EXTLD
+ }
+
+ when ($RACE == "yes") {
+ _GO_COMPILE_FLAGS_RACE=-race
+ _GO_LINK_FLAGS_RACE=-race
+ }
+ otherwise {
+ _GO_COMPILE_FLAGS_RACE=
+ _GO_LINK_FLAGS_RACE=
+ }
+
+ when ($PIC == "yes" || $PIE == "yes") {
+ _GO_COMPILE_FLAGS_SHARED=-shared
+ _GO_ASM_FLAGS_SHARED=-shared
+ }
+ otherwise {
+ _GO_COMPILE_FLAGS_SHARED=
+ _GO_ASM_FLAGS_SHARED=
+ }
+
+ GO_ASM_FLAGS_VALUE += $_GO_ASM_FLAGS_SHARED
+ GO_COMPILE_FLAGS_VALUE += $_GO_COMPILE_FLAGS_RACE $_GO_COMPILE_FLAGS_SHARED
+ GO_LINK_FLAGS_VALUE += $_GO_LINK_FLAGS_RACE
+
+ ADDINCL(${GOSTD}/runtime)
+}
+
+# tag:go-specific
+### @usage: GO_LIBRARY([name])
+###
+### Go library module definition.
+### Compile Go module as a library suitable for PEERDIR from other Go modules.
+### Will select Go implementation on PEERDIR to PROTO_LIBRARY.
+module GO_LIBRARY: _GO_BASE_UNIT {
+ .CMD=GO_LINK_LIB
+ .NODE_TYPE=Bundle
+ .FINAL_TARGET=no
+ SET(_GO_TOOL_MODE lib)
+ SET(MODULE_TYPE LIBRARY)
+ SET(PEERDIR_TAGS GO GO_PROTO GO_FBS __EMPTY__ PACKAGE_UNION)
+ _REQUIRE_EXPLICIT_LICENSE(vendor)
+
+ MODULE_SUFFIX=.a
+}
+
+# tag:go-specific
+### @usage: GO_PROGRAM([name])
+###
+### Go program module definition.
+### Compile and link Go module to an executable program.
+### Will select Go implementation on PEERDIR to PROTO_LIBRARY.
+module GO_PROGRAM: _GO_BASE_UNIT {
+ .CMD=GO_LINK_EXE
+ .NODE_TYPE=Program
+ .PROXY=yes
+ .SYMLINK_POLICY=EXE
+ .ALLOWED=INDUCED_DEPS
+ .FINAL_TARGET=yes
+ SET(MODULE_TAG GO_PROGRAM)
+ SET(_GO_TOOL_MODE exe)
+ SET(MODULE_TYPE PROGRAM)
+ SET(GO_VET_OUTPUT_INFO)
+
+ ALLOCATOR($_GO_DEFAULT_ALLOCATOR)
+
+ _USE_LINKER()
+
+ ENABLE(COMMON_LINK_SETTINGS)
+
+ when ($MUSL == "yes") {
+ PEERDIR += contrib/libs/musl/full
+ }
+ when ($RACE == "yes") {
+ PEERDIR += contrib/libs/cxxsupp/builtins
+ }
+
+ when ($MSVC == "yes" || $CYGWIN == "yes") {
+ MODULE_SUFFIX=.exe
+ }
+
+ PEERDIR(${GOSTD}/runtime library/go/core/buildinfo)
+
+ when ($RACE == "yes") {
+ PEERDIR += ${GOSTD}/runtime/cgo
+ PEERDIR += ${GOSTD}/runtime/race
+ }
+
+ when ($MUSL == "yes") {
+ GO_WITH_MUSL = ++musl
+ }
+
+ when ($HARDENING == "yes") {
+ _GO_BUILDMODE=++buildmode=pie
+ }
+}
+
+# tag:go-specific
+module _GO_DLL_BASE_UNIT: GO_PROGRAM {
+ .CMD=GO_LINK_DLL
+ .SYMLINK_POLICY=SO
+ .ALLOWED=WHOLE_ARCHIVE
+ .ARGS_PARSER=DLL
+ .NODE_TYPE=Library
+ .PROXY=yes
+ SET(_GO_TOOL_MODE dll)
+ SET(MODULE_TYPE DLL)
+
+ GO_PACKAGE_NAME(main)
+
+ when ($MSVC == "yes" || $CYGWIN == "yes") {
+ MODULE_SUFFIX=.dll
+ }
+ elsewhen ($DARWIN == "yes" || $OS_IOS == "yes") {
+ MODULE_PREFIX=lib
+ MODULE_SUFFIX=.dylib$MODULE_VERSION
+ }
+ otherwise {
+ MODULE_PREFIX=lib
+ MODULE_SUFFIX=.so$MODULE_VERSION
+ }
+
+ when ($OS_DARWIN) {
+ _GO_SONAME=-Wl,-install_name,$SONAME
+ }
+ elsewhen ($OS_LINUX) {
+ _GO_SONAME=-Wl,-soname,$SONAME
+ }
+
+ when ($MODULE_VERSION) {
+ when ($OS_LINUX || $OS_DARWIN) {
+ _GO_LINK_EXE_EXT_CMD+= && $LINK_OR_COPY_CMD $TARGET ${output;nopath;noext:SONAME}
+ }
+ }
+}
+
+# tag:go-specific
+### @usage: GO_DLL(name major_ver [minor_ver] [PREFIX prefix])
+###
+### Go ishared object module definition.
+### Compile and link Go module to a shared object.
+### Will select Go implementation on PEERDIR to PROTO_LIBRARY.
+module GO_DLL: _GO_DLL_BASE_UNIT {
+}
+
+# tag:go-specific tag:test
+### @usage: GO_BENCH_TIMEOUT(x)
+###
+### Sets timeout in seconds for 1 Benchmark in go benchmark suite
+###
+### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
+macro GO_BENCH_TIMEOUT(bench_timeout) {
+ SET(GO_BENCH_TIMEOUT $bench_timeout)
+}
+
+# tag:go-specific tag:test
+### @usage: GO_TEST([name])
+###
+### Go test module definition.
+### Compile and link Go module as a test suitable for running with Arcadia testing support.
+### All usual testing support macros like DATA, DEPENDS, SIZE, REQUIREMENTS etc. are supported.
+### Will select Go implementation on PEERDIR to PROTO_LIBRARY.
+module GO_TEST: GO_PROGRAM {
+ .CMD=GO_LINK_TEST
+ .ALIASES=GO_TEST_SRCS=GO_TEST_SRCS GO_XTEST_SRCS=GO_XTEST_SRCS GO_TEST_EMBED_PATTERN=GO_TEST_EMBED_PATTERN GO_XTEST_EMBED_PATTERN=GO_XTEST_EMBED_PATTERN GO_TEST_EMBED_DIR=GO_TEST_EMBED_DIR GO_XTEST_EMBED_DIR=GO_XTEST_EMBED_DIR
+ .ALLOWED=GO_SKIP_TESTS YT_SPEC
+ .FINAL_TARGET=no
+ SET(MODULE_TAG GO_TEST)
+ SET(PEERDIR_TAGS GO GO_PROGRAM GO_PROTO GO_FBS __EMPTY__)
+ SET(_GO_TOOL_MODE test)
+ SET(MODULE_TYPE PROGRAM)
+ ENABLE(GO_TEST_MODULE)
+ SET(GO_COVER_INFO_VALUE)
+
+ # We have to add uncoditionaly PEERDIR to ${GOSTD}/os here thouth it is really
+ # needed when TestMain is defined in the source code of the test
+ PEERDIR(${GOSTD}/os)
+
+ PEERDIR(${GOSTD}/testing/internal/testdeps)
+ PEERDIR(${GOSTD}/testing)
+
+ ADD_YTEST($MODULE_PREFIX$REALPRJNAME go.test)
+ ADD_YTEST($MODULE_PREFIX$REALPRJNAME go.bench)
+
+ SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
+}
+
+# tag:go-specific
+macro GO_MOCKGEN_FROM(Path) {
+ SET(MOCKGEN_FROM ${Path})
+}
+
+# tag:go-specific
+macro GO_MOCKGEN_TYPES(Types...) {
+ SET(MOCKGEN_TYPES ${join=\\${__COMMA__}:Types})
+}
+
+# tag:go-specific
+macro GO_MOCKGEN_REFLECT() {
+ PEERDIR(${GOSTD}/encoding/gob)
+ PEERDIR(${GOSTD}/flag)
+ PEERDIR(${GOSTD}/fmt)
+ PEERDIR(${GOSTD}/os)
+ PEERDIR(${GOSTD}/path)
+ PEERDIR(${GOSTD}/reflect)
+ PEERDIR(vendor/github.com/golang/mock/mockgen/model)
+ PEERDIR(${MOCKGEN_FROM})
+
+ RUN_PROGRAM(vendor/github.com/golang/mock/mockgen -prog_only a.yandex-team.ru/${MOCKGEN_FROM} $MOCKGEN_TYPES STDOUT main.go)
+}
+
+# tag:internal
+macro _TOOL(TOOL) {
+ .CMD=${tool:TOOL}
+}
+
+# tag:go-specific
+macro GO_MOCKGEN_MOCKS() {
+ PEERDIR(${GOSTD}/reflect)
+ PEERDIR(vendor/github.com/golang/mock/gomock)
+
+ .CMD=${tool:"vendor/github.com/golang/mock/mockgen"} -package mocks -exec_only $_TOOL($MODDIR/gen) a.yandex-team.ru/${MOCKGEN_FROM} $MOCKGEN_TYPES ${output;stdout:"main.go"}
+}