12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016 |
- # 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__NO_UID__=unknown
- when ($HOST_OS_LINUX) {
- _GO_HOST_OS__NO_UID__=linux
- }
- elsewhen ($HOST_OS_DARWIN) {
- _GO_HOST_OS__NO_UID__=darwin
- }
- elsewhen($HOST_OS_WINDOWS) {
- _GO_HOST_OS__NO_UID__=windows
- }
- GO_HOST_OS=$_GO_HOST_OS__NO_UID__
- # tag:go-specific
- _GO_HOST_ARCH__NO_UID__=unknown
- when ($HOST_ARCH_X86_64) {
- _GO_HOST_ARCH__NO_UID__=amd64
- }
- elsewhen($HOST_ARCH_ARM64) {
- _GO_HOST_ARCH__NO_UID__=arm64
- }
- GO_HOST_ARCH=$_GO_HOST_ARCH__NO_UID__
- _GO_TC_PATH=${GO_HOST_OS}_${GO_HOST_ARCH}
- # 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.21
- when ($GOSTD_VERSION == "1.21") {
- GOSTD=contrib/go/_std_1.21/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_TC_PATH/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_TC_PATH/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_TC_PATH/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_TC_PATH/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=
- GO_LINK_LIB+=$GENERATE_MF
- GO_LINK_LIB+=&& $_GO_LINK_LIB_IMPL($_GO_SRCS_VALUE CGO_FILES $_CGO_SRCS_VALUE EXTRA_TEXT_INPUTS $_GO_EMBED_INPUTS)
- GO_LINK_EXE=
- GO_LINK_EXE+=$GENERATE_MF
- GO_LINK_EXE+=&& $GENERATE_VCS_C_INFO_NODEP
- GO_LINK_EXE+=&& $GENERATE_VCS_GO_INFO_NODEP
- GO_LINK_EXE+=&& $_GO_LINK_EXE_IMPL($_GO_SRCS_VALUE CGO_FILES $_CGO_SRCS_VALUE EXTRA_TEXT_INPUTS $_GO_EMBED_INPUTS)
- GO_LINK_TEST=
- GO_LINK_TEST+=$GENERATE_VCS_C_INFO_NODEP
- GO_LINK_TEST+=&& $GENERATE_VCS_GO_INFO_NODEP
- GO_LINK_TEST+=&& $_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_DLL+=$GO_LINK_EXE
- GO_LINK_DLL+=&& $COPY_CMD $BINDIR/_cgo_export.h ${output;pre=${MODULE_PREFIX};suf=.h:REALPRJNAME}
- # tag:go-specific
- CGO_ENABLED=yes
- _GO_LINK_FLAGS_LINKMODE=
- when ($OS_WINDOWS == "yes" || $SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
- CGO_ENABLED=no
- }
- elsewhen ($CGO_ENABLED == "yes") {
- _GO_LINK_FLAGS_LINKMODE=-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 ${ARCADIA_ROOT}/${IMPORT_PATH} $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 ${ARCADIA_ROOT}/${IMPORT_PATH} $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 tag:internal
- ### @usage: _GO_EMBED_BINDIR(DIR)
- ###
- ### Define an embed directory DIR for files from ARCADIA_BUILD_ROOT
- macro _GO_EMBED_BINDIR(XTEST?"_xtest":"", PREFIX, DIR, FILES...) {
- SET_APPEND(_GO_EMBED_VALUE ++embed$XTEST ${PREFIX} $DIR ${pre=$PREFIX/:FILES})
- SET_APPEND(_GO_EMBED_INPUTS ${pre=$PREFIX/:FILES})
- }
- # tag:go-specific
- ### @usage: GO_EMBED_BINDIR(DIR)
- ###
- ### Define an embed directory DIR for files from ARCADIA_BUILD_ROOT
- macro GO_EMBED_BINDIR(PREFIX="${_GO_IMPORT_PATH}", DIR, FILES[]) {
- _GO_EMBED_BINDIR(${ARCADIA_BUILD_ROOT}/${PREFIX} $DIR $FILES)
- }
- # tag:go-specific
- ### @usage: GO_TEST_EMBED_BINDIR(DIR)
- ###
- ### Define an embed directory DIR for files from ARCADIA_BUILD_ROOT for internal go tests
- macro GO_TEST_EMBED_BINDIR(PREFIX="${_GO_IMPORT_PATH}", DIR, FILES[]) {
- _GO_EMBED_BINDIR(${ARCADIA_BUILD_ROOT}/$PREFIX $DIR $FILES)
- }
- # tag:go-specific
- ### @usage: GO_XTEST_EMBED_BINDIR(DIR, FILES...)
- ###
- ### Define an embed directory DIR for files from ARCADIA_BUILD_ROOT for external go tests
- macro GO_XTEST_EMBED_BINDIR(PREFIX="${_GO_IMPORT_PATH}", DIR, FILES[]) {
- _GO_EMBED_BINDIR(XTEST ${ARCADIA_BUILD_ROOT}/$PREFIX $DIR $FILES)
- }
- # 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 OBJADDE_LIB
- .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_TEST_EMBED_BINDIR=_GO_UNUSED_SRCS GO_XTEST_EMBED_BINDIR=_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=-migration.config=${input:"${ARCADIA_ROOT}/build/rules/go/migrations.yaml"} -scopelint.config=${input:"${ARCADIA_ROOT}/build/rules/go/extended_lint.yaml"}
- }
- 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 $OBJADDE_LIB_GLOBAL $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 $OBJADDE_LIB_GLOBAL $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_LINKMODE $_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)
- 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
- }
- when ($OPENSOURCE == "yes" && $AUTOCHECK == "yes") {
- # FIXME: Replace AUTOCHECK == yes with _not a host platform_ check after YMAKE-218
- MODULE_LICENSES_RESTRICTION_TYPES = ALLOW_ONLY
- MODULE_LICENSES_RESTRICTIONS = SERVICE REQUIRE_CITATION REQUIRE_MODIFICATIONS_DISCLOSURE
- }
- when ($OS_IOS == "yes" || $OS_ANDROID == "yes" || $MAPSMOBI_BUILD_TARGET == "yes") {
- MODULE_LICENSES_RESTRICTION_TYPES = ALLOW_ONLY
- MODULE_LICENSES_RESTRICTIONS = SERVICE REQUIRE_CITATION
- }
- }
- # 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 GO_TEST_EMBED_BINDIR=GO_TEST_EMBED_BINDIR GO_XTEST_EMBED_BINDIR=GO_XTEST_EMBED_BINDIR
- .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)
- PEERDIR(library/go/test/yatest)
- 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})
- SET(MOCKGEN_MODULE ${GO_ARCADIA_PROJECT_PREFIX}${Path})
- }
- # tag:go-specific
- macro GO_MOCKGEN_CONTRIB_FROM(Path) {
- SET(MOCKGEN_FROM ${GO_CONTRIB_PROJECT_PREFIX}${Path})
- SET(MOCKGEN_MODULE ${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/go.uber.org/mock/mockgen/model)
- PEERDIR(${MOCKGEN_FROM})
- RUN_PROGRAM(vendor/go.uber.org/mock/mockgen -prog_only $MOCKGEN_MODULE $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/go.uber.org/mock/gomock)
- .CMD=${tool:"vendor/go.uber.org/mock/mockgen"} -package mocks -exec_only $_TOOL($MODDIR/gen) ${GO_ARCADIA_PROJECT_PREFIX}${MOCKGEN_FROM} $MOCKGEN_TYPES ${output;stdout:"main.go"}
- }
|