diff options
author | snermolaev <snermolaev@yandex-team.com> | 2023-07-28 06:50:33 +0300 |
---|---|---|
committer | snermolaev <snermolaev@yandex-team.com> | 2023-07-28 06:50:33 +0300 |
commit | 10e54d8a4d3cb64929101a629dde889e91253a8c (patch) | |
tree | 6d551be3c13a1cf87da58521124150e393ef4617 | |
parent | 85ef4ee49c3edbb700d0ef903d01177bf9984018 (diff) | |
download | ydb-10e54d8a4d3cb64929101a629dde889e91253a8c.tar.gz |
move go and perl stuff to their own confs; update java.conf
-rw-r--r-- | build/conf/go.conf | 946 | ||||
-rw-r--r-- | build/conf/java.conf | 811 | ||||
-rw-r--r-- | build/conf/perl.conf | 75 | ||||
-rw-r--r-- | build/ymake.core.conf | 1837 |
4 files changed, 1835 insertions, 1834 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"} +} diff --git a/build/conf/java.conf b/build/conf/java.conf index 47982484f2..4029d59c73 100644 --- a/build/conf/java.conf +++ b/build/conf/java.conf @@ -179,3 +179,814 @@ multimodule JAVA_CONTRIB_PROGRAM { .SEM=BUILD_JAR_SEM } } + +# tag:java-specific +JAVA_VCS_MF_ARG= +COMPILE_JAVA_MF=${hide:JAVA_FAKEID} $COMPILE_JAVA $MAVEN_EXPORT_CMD + +# tag:java-specific +when ($EXT_JAVA_VCS_INFO == "yes") { + JAVA_VCS_MF_ARG=--vcs-mf $VCS_JAVA + COMPILE_JAVA_MF=${hide:JAVA_FAKEID} $GENERATE_VCS_JAVA_INFO_NODEP && $COMPILE_JAVA $MAVEN_EXPORT_CMD +} + +# tag:java-specific +EXT_JAVA_VCS_INFO=no +### @usage: EMBED_JAVA_VCS_INFO() +### +### Embed manifest with vcs info into `EXTERNAL_JAVA_LIBRARY` +### By default this is disabled. +macro EMBED_JAVA_VCS_INFO() { + .SEM=add_vcs_info_to_mf ${hide;output:"VcsInfoMfDummy.java"} + ENABLE(EXT_JAVA_VCS_INFO) +} + +# tag:java-specific tag:internal +### @usage: EXTERNAL_JAVA_LIBRARY() #internal +### +### EXTERNAL_JAVA_LIBRARY() is a module for creating a .jar file using non-Java code (generators etc.) +### Unlike regular JAVA_LIBRARY this module doesn't produce .pom file, so it cannot be exported to Maven itself. +### PEERDIR it from JAVA_LIBRARY or JAVA_PROGRAM for export to Maven. +module EXTERNAL_JAVA_LIBRARY: _BASE_UNIT { + .EXTS=.jsrc .java .jar .mf + .NODE_TYPE=Bundle + .CMD=COMPILE_JAVA_MF + # TODO(YMAKE-27) all contribs involved into opensource export must be JAVA_CONTRIB modules + # and this module must not be intended for export. Such hange will break JBUILD and thus is + # blocked on YMAKE-27 + .SEM=JAVA_CONTRIB_SEM + .PEERDIR_POLICY=as_build_from + .FINAL_TARGET=no + .ALIASES=SRCS=_SRCS_NO_GLOBAL + .ALLOWED=EMBED_JAVA_VCS_INFO + .RESTRICTED=EXTERNAL_JAR + .GLOBAL=MAVEN_EXPORT_COORDS EXPORT_GRADLE_PROJECT_COORDS + + PEERDIR(build/platform/java/jdk) + PEERDIR+=$JDK_RESOURCE_PEERDIR $EXTERNAL_JAVA_EXTRA_PEERDIR + when ($KOTLIN_PROTO == "yes") { + PEERDIR+=build/platform/java/kotlin contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${KOTLIN_VERSION} + } + + when ($MAVEN_EXPORT == "yes") { + when ($MAVEN_DEPLOY == "yes") { + PEERDIR+=build/external_resources/maven + MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM && $MAVEN_DEPLOY_CMD + } + otherwise { + MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM + } + MAVEN_EXPORT_COORDS_GLOBAL=$MAVEN_EXPORT_GOUP_ID:${MODULE_PREFIX}${REALPRJNAME}:${MAVEN_EXPORT_VERSION}: + } + + PEERDIR_TAGS=JAVA_PROTO JAVA_FBS JAVA_IDL PACKAGE_UNION + HAS_MANAGEABLE_PEERS=yes + DYNAMIC_LINK=yes + MACRO_ALIAS(PROTO_CMD _JAVA_PROTO_CMD) + MACRO_ALIAS(EVLOG_CMD _JAVA_EVLOG_CMD) + MACRO_ALIAS(FBS_CMD _JAVA_FLATC_CMD) + + when ($PACKAGE_PREFIX) { + PACKAGE_PREFIX_ARGS=--package-prefix=$PACKAGE_PREFIX + } + + DISABLE(NEED_PLATFORM_PEERDIRS) + NO_PLATFORM() + SET(MODULE_SUFFIX .jar) + SET(MODULE_LANG JAVA) + + _WHEN_EXPORT_GRADLE() +} + +# tag:java-specific +ALL_JAR_SOURCES= +LINT_JAVA_SOURCES= +ALL_SRCDIRS= +LINK_JAR_RESOURCES= +LINK_JAR_JSOURCES= +JAR_GEN_SRCS= +JAR_GEN_JSRCS= +macro _JAR_SRCS(SRCDIR=".", PACKAGE_PREFIX="", EXCLUDE[], FILES[], RESOURCES?"yes":"no", Globs...) { + _CHECK_JAVA_SRCDIR($SRCDIR) + SET_APPEND(ALL_SRCDIRS $SRCDIR) + SET(VAR_SALT $SRCDIR $Globs $EXCLUDE $PACKAGE_PREFIX $RESOURCES $FILES) + SET(JAR_SRCS_GLOB uniq_${hash:VAR_SALT}) + _LATE_GLOB(${JAR_SRCS_GLOB} ${pre=${SRCDIR}/:Globs} EXCLUDE ${EXCLUDE}) + SET_APPEND(LINT_JAVA_SOURCES \${input;rootrel;ext=.java:${JAR_SRCS_GLOB}}) + SET_APPEND(ALL_JAR_SOURCES --jsources ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt --resources ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt --srcdir ${quo:SRCDIR} \${input:${JAR_SRCS_GLOB}} ${pre=\$\{input\:\";suf=\"\}:FILES}) + _FILL_JAR_COPY_RESOURCES_CMD(LINK_JAR_RESOURCES ${quo:SRCDIR} ${BINDIR}/cls ${PACKAGE_PREFIX} ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt) + _FILL_JAR_COPY_RESOURCES_CMD(LINK_JAR_JSOURCES ${quo:SRCDIR} ${BINDIR}/src ${PACKAGE_PREFIX} ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt) + _FILL_JAR_GEN_SRCS(JAR_GEN_SRCS JAR $SRCDIR ${BINDIR}/cls ${BINDIR}/all-java.srclst $KT_SRCLIST ${BINDIR}/misc/all-gr-sources.txt ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt $Globs EXCLUDE $EXCLUDE) + _FILL_JAR_GEN_SRCS(JAR_GEN_JSRCS SRC_JAR $SRCDIR ${BINDIR}/cls ${BINDIR}/all-java.srclst $KT_SRCLIST ${BINDIR}/misc/all-gr-sources.txt ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt $Globs EXCLUDE $EXCLUDE) +} + +macro IDEA_JAR_SRCS(Args...) { + _JAR_SRCS($Args) + SET_APPEND(JAVA_SRCS_VALUE $ARGS_DELIM $Args) +} + +macro _HASH_HELPER(Args...) { + .CMD=${hash:Args} + .SEM=${hash:Args} +} + +macro _GENTAR_HELPER(OUT_DIR[], Args...) { + .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/autotar_gendirs.py"} --pack ${OUT_DIR} --outs ${output;tared;suf=.$_HASH_HELPER($Args).gentar:OUT_DIR} ${kv;hide:"tared_kind nodir"} +} + +# tag:java-specific +RUN_JAR_PROG_CP_PRE=@ +RUN_JAR_PROG_CP_SUF=.cplst +when($JDK_VERSION == "8") { + RUN_JAR_PROG_CP_PRE= + RUN_JAR_PROG_CP_SUF= +} + +# tag:java-specific +JDK_LATEST_VERSION=19 +JDK_LATEST_PEERDIR=build/platform/java/jdk/jdk${JDK_LATEST_VERSION} + +# tag:java-specific +macro _DO_2_RUN_JAR_PROGRAM(IN_DIRS_VAR="uniq_", IN_DIRS_INPUTS[], IN{input}[], IN_NOPARSE{input}[], IN_DIR[], OUT_NOAUTO{output}[], OUT{output}[], TOOL{tool}[], OUT_DIR[], CLASSPATH[], ADD_SRCS_TO_CLASSPATH?"yes":"no", CWD="${ARCADIA_BUILD_ROOT}", STDOUT="", STDOUT_NOAUTO="", Args...) { + _LATE_GLOB(${IN_DIRS_VAR} ${suf=/**/*:IN_DIR}) + _CHECK_RUN_JAVA_PROG_CLASSPATH($CLASSPATH) + .PEERDIR=build/platform/java/jdk $JDK_RESOURCE_PEERDIR + .CMD=${kv;hide:"p RJ"} ${kv;hide:"pc blue"} ${hide:JAVA_FAKEID} ${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/mkdir.py"} ${OUT_DIR} && ${cwd:CWD} $YMAKE_PYTHON ${input:"build/scripts/setup_java_tmpdir.py"} $YMAKE_PYTHON ${input:"build/scripts/stdout2stderr.py"} ${pre=--file=:STDOUT} ${output;hide:STDOUT} ${pre=--file=:STDOUT_NOAUTO} ${output;hide;noauto:STDOUT_NOAUTO} $YMAKE_PYTHON ${input:"build/scripts/fix_java_command_file_cp.py"} --build-root ${ARCADIA_BUILD_ROOT} $JDK_RESOURCE/bin/java -Dfile.encoding=utf8 -classpath ${RUN_JAR_PROG_CP_PRE}${tool:CLASSPATH}${RUN_JAR_PROG_CP_SUF} ${Args} && $_GENTAR_HELPER($CLASSPATH $IN_DIR $IN $IN_NOPARSE $TOOL $Args OUT_DIR $OUT_DIR) ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output;noauto;hide:OUT_NOAUTO} ${output;hide:OUT} ${tool;hide:TOOL} ${IN_DIRS_INPUTS} +} + +# tag:java-specific +macro _DO_1_RUN_JAR_PROGRAM(IN_DIRS_VAR="uniq", Args...) { + _DO_2_RUN_JAR_PROGRAM($Args IN_DIRS_VAR $IN_DIRS_VAR IN_DIRS_INPUTS ${"$"}{input;hide:$IN_DIRS_VAR}) +} + +# tag:java-specific +macro RUN_JAVA_PROGRAM(Args...) { + _DO_1_RUN_JAR_PROGRAM($Args IN_DIRS_VAR uniq_${hash:Args}) +} + +# tag:java-specific +_JAR_ANN_PROCESSORS= +_JAR_ANN_PROC_OPT_PREFIX= +macro JAR_ANNOTATION_PROCESSOR(Classes...) { + SET_APPEND(_JAR_ANN_PROCESSORS $Classes) + SET(_JAR_ANN_PROC_OPT_PREFIX -processor) + + # for ya ide idea only + SET_APPEND(ANNOTATION_PROCESSOR_VALUE $ARGS_DELIM $Classes) +} + +# tag:java-specific +macro _JAR_ANN_PROC_OPTS(Classes...) { + .CMD=$_JAR_ANN_PROC_OPT_PREFIX ${join=,:Classes} +} + +# tag:java-specific +macro _NOOP_MACRO(Args...) { + ENABLE(UNUSED_MACRO) +} + +# tag:java-specific +module _JAR_BASE: _BARE_UNIT { + .NODE_TYPE=Bundle + .CMD=TOUCH_UNIT + .PEERDIR_POLICY=as_build_from + .FINAL_TARGET=no + .ALIASES=SRCS=_SRCS_NO_GLOBAL + .ALLOWED=EMBED_JAVA_VCS_INFO DEPENDENCY_MANAGEMENT EXCLUDE + .DEFAULT_NAME_GENERATOR=TwoDirNames + .RESTRICTED=WITH_JDK RESOURCE RESOURCE_FILES + .GLOBAL=EXPORT_GRADLE_PROJECT_COORDS + + PEERDIR_TAGS=JAVA_PROTO JAVA_FBS JAVA_IDL DLL JAR_COMPILATION __EMPTY__ + + HAS_MANAGEABLE_PEERS=yes + DYNAMIC_LINK=yes + MACRO_ALIAS(PROTO_CMD _JAVA_PROTO_CMD) + MACRO_ALIAS(EVLOG_CMD _JAVA_EVLOG_CMD) + MACRO_ALIAS(FBS_CMD _JAVA_FLATC_CMD) + + DISABLE(NEED_PLATFORM_PEERDIRS) + NO_PLATFORM() + VCS_JAVA=${suf=.__vcs_version__.mf:TARGET} + SET(MODULE_LANG JAVA) + + _WHEN_EXPORT_GRADLE() +} + +JAVA_CONTRIB_PROXY_SEM=IGNORED +# tag:java-specific +module JAVA_CONTRIB_PROXY: _JAR_BASE { + .SEM=JAVA_CONTRIB_PROXY_SEM +} + +# tag:java-specific +macro _FETCH_CONTRIB(Id, Out, SBR="sbr:") { + .CMD=${hide:SANDBOX_FAKEID} ${cwd:BINDIR} ${resource;pre=$SBR:Id} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_sandbox.py"} --resource-file $(RESOURCE_ROOT)/sbr/$Id/resource --resource-id $Id --copy-to ${output:Out} ${input;hide:"build/scripts/fetch_from.py"} ${requirements;hide:"network:full"} ${kv;hide:"p SB"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"} + ADD_CHECK(check.resource $Id) +} + +# tag:java-specific +LOCAL_JAR_PATH= +LOCAL_SOURCES_JAR_PATH= +JAR_RESOURCE_ID= +SRC_RESOURCE_ID= +FETCH_SRCS_JAR= +FETCH_TARGET_JAR= +FETCH_CONTRIB_JAR=${hide:JAVA_FAKEID} $FETCH_TARGET_JAR $FETCH_SRCS_JAR + +# tag:java-specific +macro JAR_RESOURCE(Id) { + SET(JAR_RESOURCE_ID $Id) +} + +# tag:java-specific +macro SRC_RESOURCE(Id) { + SET(SRC_RESOURCE_ID $Id) +} + +# tag:java-specific +macro LOCAL_JAR(File) { + SET(LOCAL_JAR_PATH $File) +} + +# tag:java-specific +macro LOCAL_SOURCES_JAR(File) { + SET(LOCAL_SOURCES_JAR_PATH $File) +} + +JAVA_CONTRIB_SEM= \ + consumer_classpath $EXPORT_GRADLE_PROJECT_COORDS ${hide:TARGET} ${hide:AUTO_INPUT} && \ + peers_closure $MANAGED_PEERS_CLOSURE && \ + peers_closure_coords $EXPORT_GRADLE_PROJECT_COORDS_GLOBAL && \ + IGNORED + +# tag:java-specific +module JAVA_CONTRIB: _JAR_BASE { + .CMD=FETCH_CONTRIB_JAR + .SEM=JAVA_CONTRIB_SEM + .FINAL_TARGET=yes + .GLOBAL=MAVEN_EXPORT_COORDS EXPORT_GRADLE_PROJECT_COORDS + + when ($JAR_RESOURCE_ID) { + FETCH_TARGET_JAR= && $_FETCH_CONTRIB($JAR_RESOURCE_ID ${BINDIR}/${MODULE_PREFIX}${REALPRJNAME}${MODULE_SUFFIX}) + } + otherwise { + when ($LOCAL_JAR_PATH) { + FETCH_TARGET_JAR= && $FS_TOOLS copy ${input:LOCAL_JAR_PATH} $TARGET + } + otherwise { + FETCH_TARGET_JAR= && $GENERATE_VCS_JAVA_INFO_NODEP && ${cwd:BINDIR} $JDK_RESOURCE/bin/jar cfvm $TARGET $VCS_JAVA . + PEERDIR+=build/platform/java/jdk + PEERDIR+=$JDK_RESOURCE_PEERDIR + } + } + when ($SRC_RESOURCE_ID) { + FETCH_SRCS_JAR= && $_FETCH_CONTRIB($SRC_RESOURCE_ID ${BINDIR}/${REALPRJNAME}-sources.jar) + } + otherwise { + when ($LOCAL_SOURCES_JAR_PATH) { + FETCH_SRCS_JAR= && $FS_TOOLS copy ${input:LOCAL_SOURCES_JAR_PATH} {output;pre=${BINDIR}/;suf=-sources.jar:REALPRJNAME} + } + otherwise { + FETCH_SRCS_JAR= && $GENERATE_VCS_JAVA_INFO_NODEP && $FS_TOOLS md ${BINDIR}/fake-src && ${cwd;suf=/fake-src:BINDIR} $JDK_RESOURCE/bin/jar cfvm ${output;pre=${BINDIR}/;suf=-sources.jar:REALPRJNAME} $VCS_JAVA . + PEERDIR+=build/platform/java/jdk + PEERDIR+=$JDK_RESOURCE_PEERDIR + } + } + when ($MAVEN_EXPORT == "yes") { + _MAKEFILE_INCLUDE_LIKE_DEPS+=pom.xml + FETCH_CONTRIB_JAR+= && $MAVEN_EXPORT_GEN_DEPLST + } + + SET(MODULE_SUFFIX .jar) + _SETUP_MAVEN_EXPORT_COORDS_IF_NEED($MODDIR) +} + +MAKE_JAVA_CLASSPATH_FILE=$YMAKE_PYTHON ${input:"build/scripts/make_java_classpath_file.py"} ${input;hide:"build/scripts/process_command_files.py"} + +# tag:kotlin-specific +KOTLINC_OPTS_VALUE= + +# tag:kotlin-specific +KT_SRCLIST=${BINDIR}/misc/all-kt-sources.txt +KT_SRSCLIST_FLAG=--kotlin $KT_SRCLIST +KT_CLASSES_DIR=${BINDIR}/kt_cls +KT_CLASSPATH=${BINDIR}/kt_cp.txt +COLLECT_KT_CLASSPATH=${WRITER_PY} --file ${BINDIR}/kt_bfg.txt -m --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} --ya-end-command-file +LINK_KT_CLASSPATH=${MAKE_JAVA_CLASSPATH_FILE} ${BINDIR}/kt_bfg.txt $KT_CLASSPATH && $FS_TOOLS md $KT_CLASSES_DIR +COMPILE_KT= \ + ${cwd:ARCADIA_BUILD_ROOT} ${env:"LC_ALL=en_US.UTF-8"} $YMAKE_PYTHON ${input:"build/scripts/with_pathsep_resolve.py"} $YMAKE_PYTHON ${input:"build/scripts/run_javac.py"} --kotlin --sources-list $KT_SRCLIST \ + $JDK_RESOURCE/bin/java -jar $KOTLIN_COMPILER_RESOURCE_GLOBAL/kotlin-compiler.jar -no-stdlib -module-name $REALPRJNAME -jvm-target ${KOTLIN_JVM_TARGET} \ + @$KT_SRCLIST -classpath @$KT_CLASSPATH $KOTLINC_FLAGS_VALUE -d $KT_CLASSES_DIR $KOTLINC_OPTS_VALUE +ALL_KT_COMMANDS= +KT_CLASSPATH_ITEM= + +# tag:kotlin-specific +KT_KAPT_SOURCES_DIR=${BINDIR}/kapt_gen_src +KT_KAPT_STUBS_DIR=${BINDIR}/kapt_gen_stubs +KT_KAPT_AP_CLASSPATH= +KT_KAPT_PLUGIN_OPTS=-P plugin:org.jetbrains.kotlin.kapt3:sources=${KT_KAPT_SOURCES_DIR} -P plugin:org.jetbrains.kotlin.kapt3:classes=${KT_CLASSES_DIR} -P plugin:org.jetbrains.kotlin.kapt3:stubs=${KT_KAPT_STUBS_DIR} -P plugin:org.jetbrains.kotlin.kapt3:aptMode=stubsAndApt +### @usage: KAPT_OPTS(opts...) +### +### Used to specify annotation processor qualified class names. +### If specified multiple times, only last specification is used. +macro KAPT_OPTS(Args...) { + SET_APPEND(KT_KAPT_PLUGIN_OPTS ${pre=-P :Args}) +} +### @usage: KAPT_ANNOTATION_PROCESSOR(processors...) +### +### Used to specify annotation processor qualified class names. +### If specified multiple times, only last specification is used. +macro KAPT_ANNOTATION_PROCESSOR(Args...) { + KAPT_OPTS(${pre="plugin:org.jetbrains.kotlin.kapt3:processors=":Args}) +} +### @usage: KAPT_ANNOTATION_PROCESSOR_CLASSPATH(jars...) +### +### Used to specify classpath for annotation processors. +### If specified multiple times, all specifications are used. +macro KAPT_ANNOTATION_PROCESSOR_CLASSPATH(Args...) { + PEERDIR($Args) + SET_APPEND(KT_KAPT_AP_CLASSPATH $Args) +} + +# tag:java-specific +JAVAC_CMD=$JDK_RESOURCE/bin/javac +ERROR_PRONE_JAVAC_CMD=${YMAKE_PYTHON} ${input:"build/scripts/build_java_with_error_prone2.py"} $JDK_RESOURCE/bin/java $JDK_RESOURCE/bin/javac $ERROR_PRONE_RESOURCE/error_prone.jar + +# tag:java-specific tag:codenav +JAVA_YNDEXING=no + +# tag:java-specific +when ($USE_SYSTEM_KYTHE) { + KYTHE_RESOURCE=$USE_SYSTEM_KYTHE +} +otherwise { + KYTHE_RESOURCE=$KYTHE_RESOURCE_GLOBAL +} + +# tag:java-specific tag:codenav +_JAVA_YNDEXING_CMD=$YMAKE_PYTHON ${input:"build/scripts/build_java_codenav_index.py"} $TARGET $ARCADIA_BUILD_ROOT $ARCADIA_ROOT ${BINDIR}/all-java.srclst $JDK_RESOURCE/bin/java -jar $KYTHE_RESOURCE/kythe/extractors/javac_extractor.jar +_DO_JAVA_YNDEXING= + +# tag:java-specific +SOURCES_JAR=no +when ($BUILD_TYPE == "DEBUG" && $NO_DEBUGINFO != "yes") { + SOURCES_JAR=yes +} + +_PACK_SRC_JAR_IMPL=&& $FS_TOOLS md ${BINDIR}/src $JAR_GEN_JSRCS $LINK_JAR_JSOURCES && ${cwd;suf=/src:BINDIR} $JDK_RESOURCE/bin/jar cfvm ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME} $VCS_JAVA . +_PACK_SRC_JAR= + +# tag:java-specific +_PACK_JNI= +_PACK_JNI_CMD= && $FS_TOOLS link_or_copy_to_dir --ya-start-command-file ${ext=.so:MANAGED_PEERS_CLOSURE} ${ext=.dll:MANAGED_PEERS_CLOSURE} ${ext=.dylib:MANAGED_PEERS_CLOSURE} --ya-end-command-file ${BINDIR}/cls + +# tag:java-specific +_MAKE_JSTYLE_FILE_LIST= + +# tag:java-specific +_LINK_UBERJAR= +_UBERJAR_SELF= +_DO_LINK_UBERJAR= && $JDK_RESOURCE/bin/java -cp $UBERJAR_RESOURCE/devtools-java_shader.jar ru.yandex.devtools.emigrante.Main --out-jar $TARGET $_UBERJAR_SELF ${ext=.jar;pre=--jar :MANAGED_PEERS_CLOSURE} ${UBERJAR_PREFIX_FLAG} ${UBERJAR_HIDE_EXCLUDE_FLAGS} $UBERJAR_PATH_EXCLUDES ${UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG} ${UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS} ${UBERJAR_APPENDING_TRANSFORMER_FLAGS} ${UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG} \ + && $YMAKE_PYTHON ${input:"build/scripts/mkdir.py"} $BINDIR/_empty/META-INF \ + && $YMAKE_PYTHON ${input:"build/scripts/touch.py"} $BINDIR/_empty/META-INF/MANIFEST.MF \ + && $UPDATE_VCS_JAVA_INFO_NODEP($TARGET) \ + && ${cwd;suf=/_empty:BINDIR} ${JDK_RESOURCE}/bin/jar ufv ${TARGET} META-INF/MANIFEST.MF \ + && $JDK_RESOURCE/bin/jar ufvm $TARGET $VCS_JAVA + +# tag:java-specific +macro _PACK_JAR_HELPER(Out) { + .CMD=${cwd;suf=/cls:BINDIR} ${env:"LC_ALL=en_US.UTF-8"} $JDK_RESOURCE/bin/jar cfvm $Out $VCS_JAVA . +} + +# tag:java-specific +macro _JAVAC_RUN_HELPER(JAVAC_CMD_WITH_ARGS...) { + .CMD=${cwd:ARCADIA_BUILD_ROOT} ${env:"LC_ALL=en_US.UTF-8"} $YMAKE_PYTHON ${input:"build/scripts/with_pathsep_resolve.py"} $YMAKE_PYTHON ${input:"build/scripts/setup_java_tmpdir.py"} $YMAKE_PYTHON ${input:"build/scripts/run_javac.py"} --sources-list ${BINDIR}/all-java.srclst ${JAVAC_CMD_WITH_ARGS} @${BINDIR}/all-java.srclst -classpath ${ARCADIA_BUILD_ROOT}/bfg.jar -Xpkginfo:always ${JAVAC_OPTS} $_JAR_ANN_PROC_OPTS($_JAR_ANN_PROCESSORS) -d ${BINDIR}/cls -g -encoding UTF-8 +} +macro _ADD_HIDDEN_INPUTS(Inputs...) { + .CMD=${input;hide:Inputs} +} + +# tag:java-specific +ERROR_PRONE_JDK16_ADD_OPENS=-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED +ERROR_PRONE_2_7_1_FORCED_OPTS=-Xep:InlineMeInliner:OFF -Xep:SameNameButDifferent:OFF + +# tag:java-specific +macro _ADD_OPTS_IF_NON_EMPTY(Opt, Args...) { + .CMD=${pre=$Opt :Args} +} +macro _ADD_GEN_POM_FROM_COORD_FILES_ARGS(Deps...) { + .CMD=${pre=--deps-coords ;ext=.jar;suf=.mvn_coords:Deps} +} +MAVEN_EXPORT_OUT_DIR_FLAG=$_ADD_OPTS_IF_NON_EMPTY(--output-dir ${MAVEN_EXPORT_OUT_DIR}) +MAVEN_EXPORT_SOURCE_DIRS=$_ADD_OPTS_IF_NON_EMPTY(--source-dirs ${ALL_SRCDIRS}) +MAVEN_EXPORT_DEPS_COORS=$_ADD_GEN_POM_FROM_COORD_FILES_ARGS(${MANAGED_PEERS_CLOSURE}) +MAVEN_EXPORT_OUT_DIR= + +MAVEN_EXPORT=no +MAVEN_DEPLOY=no +MAVEN_DEPLOY_SOURCES= +MAVEN_EXPORT_VERSION={vcs_revision} +MAVEN_EXPORT_GEN_DEPLST= \ + $WRITER_PY \ + --file ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.mvn_coords:REALPRJNAME} \ + --ya-start-command-file -m ${pre=D=:MAVEN_EXPORT_COORDS_GLOBAL} ${pre=E=:EXCLUDED_MAVEN_EXPORT_COORDS_GLOBAL} --ya-end-command-file \ + ${hide:APPLIED_EXCLUDES} +MAVEN_EXPORT_GEN_POM=${kv;hide:"mvn_export yes"} \ + $YMAKE_PYTHON ${input:"build/scripts/generate_pom.py"} \ + --from-coord-files \ + --vcs-info $(VCS)/vcs.json \ + --target-path $MODDIR \ + $MAVEN_EXPORT_SOURCE_DIRS \ + $MAVEN_EXPORT_DEPS_COORS \ + $MAVEN_EXPORT_OUT_DIR_FLAG \ + --target-coords ${suf=.mvn_coords:TARGET} \ + --pom-path ${output:"pom.xml"} + +MAVEN_DEPLOY_CMD=$YMAKE_PYTHON ${input:"build/scripts/stdout2stderr.py"} $MAVEN_BIN \ + deploy:deploy-file -DpomFile=$BINDIR/pom.xml \ + -Dfile=$TARGET -DrepositoryId=$MAVEN_REPO_ID -Durl=$MAVEN_REPO_URL -Djava.net.preferIPv4Addresses=false -Djava.net.preferIPv6Addresses=true \ + ${MAVEN_DEPLOY_SOURCES} \ + $_ADD_OPTS_IF_NON_EMPTY(-gs $MAVEN_EXPORT_SETTINGS) \ + $_ADD_OPTS_IF_NON_EMPTY(-s $MAVEN_EXPORT_SETTINGS) +MAVEN_EXPORT_CMD= + +# tag:java-specific +JAVA_COVERAGE_SRCLIST_FLAG=--coverage ${output;pre=${MODULE_PREFIX};suf=.cpsf:REALPRJNAME} --source-root ${ARCADIA_ROOT} +JAVA_COVERAGE_SRCLIST= +PREPARE_JAVA_BUILD_DIRS=$FS_TOOLS md ${BINDIR}/cls && $FS_TOOLS md ${BINDIR}/misc +EXTRACT_GENDIRS=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/autotar_gendirs.py"} --unpack --ext .gentar ${ext=.gentar:AUTO_INPUT} +COLLECT_JAVA_SRCLIST=${YMAKE_PYTHON} ${input:"build/scripts/make_java_srclists.py"} ${input;hide:"build/scripts/process_command_files.py"} ${input;hide:"build/scripts/java_pack_to_file.py"} --moddir ${CURDIR} --java ${BINDIR}/all-java.srclst ${KT_SRSCLIST} ${JAVA_COVERAGE_SRCLIST} --ya-start-command-file ${ALL_JAR_SOURCES} ${ext=.java:AUTO_INPUT} ${ext=.kt:AUTO_INPUT} --ya-end-command-file +COLLECT_CLASSPATH=${WRITER_PY} --file ${BINDIR}/bfg.txt -m --ya-start-command-file ${rootrel:MANAGED_PEERS_CLOSURE} $KT_CLASSPATH_ITEM --ya-end-command-file +LINK_CLASSPATH=${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/bfg.txt ${ARCADIA_BUILD_ROOT}/bfg.jar +COMPILE_JAVA_SRCLIST=$_JAVAC_RUN_HELPER($JAVAC_CMD) +PACK_JAR=$_PACK_JAR_HELPER($TARGET) +# NOTE: No && before LINK_JAR_RESOURCES, ALL_KT_COMMANDS and JAR_GEN_SRCS needed since those vars either empty or starts with && +LINK_JAR=${hide:JAVA_FAKEID} ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} ${requirements;hide:"cpu:2"} \ + $PREPARE_JAVA_BUILD_DIRS \ + && $EXTRACT_GENDIRS \ + && $COLLECT_JAVA_SRCLIST \ + $JAR_GEN_SRCS \ + $ALL_KT_COMMANDS \ + && $COLLECT_CLASSPATH \ + && $LINK_CLASSPATH \ + && $COMPILE_JAVA_SRCLIST \ + $LINK_JAR_RESOURCES \ + && ${cwd;suf=/cls:BINDIR} $GENERATE_VCS_JAVA_INFO_NODEP . \ + $_PACK_SRC_JAR \ + $_PACK_JNI \ + && $PACK_JAR \ + $_DO_JAVA_YNDEXING \ + $_MAKE_JSTYLE_FILE_LIST \ + $_LINK_UBERJAR \ + $MAVEN_EXPORT_CMD \ + $_ADD_HIDDEN_INPUTS($JAVA_EXTERNAL_DEPENDENCIES_VALUE) + +# tag:java-specific +_EXT_SRC_JAR= +_EXT_JAR= +_COPY_EXT_SRC_JAR= && $FS_TOOLS md ${BINDIR}/empty && ${cwd;suf=/empty:BINDIR} $JDK_RESOURCE/bin/jar cfvM ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME} . +_DO_USE_EXT_JAR=${hide:JAVA_FAKEID} $FS_TOOLS copy ${input:_EXT_JAR} $TARGET $_COPY_EXT_SRC_JAR $MAVEN_EXPORT_CMD +_DO_COPY_EXT_SRC_JAR= && $FS_TOOLS copy $_EXT_SRC_JAR ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME} +macro JAVA_RESOURCE(JAR, SOURCES="") { + SET(_EXT_SRC_JAR $SOURCES) + SET(_EXT_JAR $JAR) +} + +# tag:java-specific tag:fbs +JAVA_FLATBUFFERS_VERSION = 2.0.0 + +# tag:java-specific +module _COMPILABLE_JAR_BASE : _JAR_BASE { + # flatbuffers-java + DEPENDENCY_MANAGEMENT(contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION}) + CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/flatbuffers/flatbuffers-java EXCEPT contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION}) + + # protobuf-java + DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION}) + CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-java EXCEPT contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION}) + + # protobuf-javalite + DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION}) + CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-javalite EXCEPT contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION}) + + # protobuf-java-util + DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java-util/${JAVA_PROTO_RUNTIME_VERSION}) + CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-java-util EXCEPT contrib/java/com/google/protobuf/protobuf-java-util/${JAVA_PROTO_RUNTIME_VERSION}) +} + +_JAR_MAIN_CLASS= +macro JAR_MAIN_CLASS(Class) { + SET(_JAR_MAIN_CLASS ${Class}) +} + +_JAR_MAIN_SEM= +_ADD_JAR_MAIN_SEM= && app_main_class ${_JAR_MAIN_CLASS} + +GRADLE_EXPORT_PUBLISHING=no +_GRADLE_EXPORT_PUBLISHING_SEM= +PUBLISH_MAVEN_VERSION=no +_DO_GRADLE_EXPORT_PUBLISHING_SEM= && publish True && publish_group $MAVEN_EXPORT_GOUP_ID && publish_version $PUBLISH_MAVEN_VERSION + +BUILD_JAR_SEM= \ + jar $MODDIR $REALPRJNAME ${hide:TARGET} ${hide:AUTO_INPUT} && \ + applied_excludes $EXCLUDED_EXPORT_GRADLE_PROJECT_COORDS_GLOBAL ${hide:APPLIED_EXCLUDES} && \ + excludes_rules $EXCLUDE_VALUE && \ + consumer_classpath $EXPORT_GRADLE_PROJECT_COORDS $_JAR_MAIN_SEM $_GRADLE_EXPORT_PUBLISHING_SEM + +### _EXPORT_GRADLE_TARGET_ATTR(NAME, VALUE...) +### +### Add target attribute `NAME` for .SEM if `VALUE` is non-empty +### ` && $Name $Value +macro _EXPORT_GRADLE_TARGET_ATTR(NAME, VALUE...) { + .SEM=${pre= && $NAME :VALUE} +} + +BUILD_PROTO_JAR_SEM= \ + jar_proto $MODDIR $REALPRJNAME ${hide:target} ${hide:AUTO_INPUT} && \ + consumer_classpath $EXPORT_GRADLE_PROJECT_COORDS $_EXPORT_GRADLE_TARGET_ATTR(proto_namespace $PROTO_NAMESPACE) $_EXPORT_GRADLE_TARGET_ATTR(proto_grpc ${ext=yes:_GRPC_ENABLED}) + +# tag:java-specific tag:internal +### @usage: JAR_LIBRARY() #internal +### +### Reimplementation of the JAVA_LIBRARY with ymake.core.conf and ymake based dependency management +module JAR_LIBRARY: _COMPILABLE_JAR_BASE { + .EXTS=.jsrc .java .jar .mf .gentar .kt + .CMD=LINK_JAR + .SEM=BUILD_JAR_SEM + .FINAL_TARGET=yes + .ALIASES=JAVA_SRCS=IDEA_JAR_SRCS ANNOTATION_PROCESSOR=JAR_ANNOTATION_PROCESSOR + .RESTRICTED=EXTERNAL_JAR + .GLOBAL=MAVEN_EXPORT_COORDS EXPORT_GRADLE_PROJECT_COORDS + MODULE_SUFFIX=.jar + + PEERDIR(build/platform/java/jdk) + PEERDIR+=$JDK_RESOURCE_PEERDIR + + when ($_EXT_SRC_JAR) { + _COPY_EXT_SRC_JAR=_DO_COPY_EXT_SRC_JAR + } + when ($_EXT_JAR) { + LINK_JAR=$_DO_USE_EXT_JAR + } + when ($OPENSOURCE_EXPORT == "no") { + BUILD_JAR_SEM=IGNORED + } + when ($_JAR_MAIN_CLASS) { + _JAR_MAIN_SEM=$_ADD_JAR_MAIN_SEM + } + when ($GRADLE_EXPORT_PUBLISHING == "yes") { + _GRADLE_EXPORT_PUBLISHING_SEM=$_DO_GRADLE_EXPORT_PUBLISHING_SEM + } + + # in the ideal world this statement must be under condition bellow + DEPENDENCY_MANAGEMENT(contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${KOTLIN_VERSION}) + when ($WITH_KOTLIN_VALUE) { + KT_SRSCLIST=$KT_SRSCLIST_FLAG + _MAKE_LINT_KT_FILES_LIST = $YMAKE_PYTHON ${input:"build/scripts/kt_copy.py"} $KT_SRCLIST ${output;noauto:"all-kt-sources.txt"} $(SOURCE_ROOT) $(BUILD_ROOT) + ALL_KT_COMMANDS=&& $COLLECT_KT_CLASSPATH && $LINK_KT_CLASSPATH + when ($WITH_KAPT_VALUE == "yes") { + # For Kapt usage see: https://kotlinlang.org/docs/kapt.html#using-in-cli + # See for kapt.kotlin.generated: https://github.com/JetBrains/kotlin/blob/master/plugins/kapt3/kapt3-cli/testData/integration/kotlinFileGeneration/build.txt + _KAPT_OPTS=-Xplugin=${tool:"contrib/java/org/jetbrains/kotlin/kotlin-annotation-processing/1.8.20"} $KT_KAPT_PLUGIN_OPTS + _RUN_KAPT=${YMAKE_PYTHON} ${input:"build/scripts/with_kapt_args.py"} ${pre=--ap-classpath :KT_KAPT_AP_CLASSPATH} -- $COMPILE_KT $_KAPT_OPTS + _APPEND_KAPT_GENERATED_SRCS=$YMAKE_PYTHON ${input:"build/scripts/resolve_java_srcs.py"} -d $KT_KAPT_SOURCES_DIR --include-patterns '**/*.java' '**/*.kt' --resolve-kotlin --append -s ${BINDIR}/all-java.srclst -k $KT_SRCLIST -r ${BINDIR}/not-used.txt + + ALL_KT_COMMANDS+=&& $_RUN_KAPT && $_APPEND_KAPT_GENERATED_SRCS + } + ALL_KT_COMMANDS+=&& $COMPILE_KT && $_MAKE_LINT_KT_FILES_LIST + LINK_JAR_RESOURCES+=&& $FS_TOOLS copy_all_files ${KT_CLASSES_DIR} ${BINDIR}/cls + PEERDIR+=build/platform/java/kotlin contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8 + when($WITH_KOTLINC_PLUGIN_ALLOPEN) { + KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-allopen-plugin.jar + } + when($WITH_KOTLINC_PLUGIN_LOMBOK) { + KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-lombok-plugin.jar + } + when($WITH_KOTLINC_PLUGIN_NOARG) { + KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-noarg-plugin.jar + } + when($WITH_KOTLINC_PLUGIN_SERIALIZATION) { + KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-serialization-plugin.jar + } + # Must be in sync with KT_CLASSES_DIR! + # There are problems in JDK13 with abs paths in classpath baked into jar file manifest. Using relative path + # here assumes that jar file with classpath for javac located in the $ARCADIA_BUILD_ROOT + KT_CLASSPATH_ITEM=$MODDIR/kt_cls + } + otherwise { + KT_SRSCLIST= + ALL_KT_COMMANDS= + KT_CLASSES= + } + + when ($MAVEN_EXPORT == "yes") { + when ($MAVEN_DEPLOY == "yes") { + PEERDIR+=build/external_resources/maven + MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM && $MAVEN_DEPLOY_CMD + } + otherwise { + MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM + } + MAVEN_EXPORT_COORDS_GLOBAL=$MAVEN_EXPORT_GOUP_ID:${MODULE_PREFIX}${REALPRJNAME}:${MAVEN_EXPORT_VERSION}: + } + + when ($SOURCES_JAR == "yes") { + _PACK_SRC_JAR=$_PACK_SRC_JAR_IMPL + MAVEN_DEPLOY_SOURCES=-Dsources=${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME} + } + + when ($JAVA_COVERAGE == "yes") { + JAVA_COVERAGE_SRCLIST=$JAVA_COVERAGE_SRCLIST_FLAG + } + + when ($MAKE_UBERJAR_VALUE == "yes") { + _LINK_UBERJAR=$_DO_LINK_UBERJAR + PACK_JAR=$_PACK_JAR_HELPER(${BINDIR}/${REALPRJNAME}.lib.jar) + # TODO: This condition is incorrect in case of autoinputs _UBERJAR_SELF should be empty only for + # modules without AUTO_INPUT and without JAVA_SRCS added inputs. + when($ALL_JAR_SOURCES) { + _UBERJAR_SELF=--jar ${BINDIR}/${REALPRJNAME}.lib.jar + } + PEERDIR+=build/platform/java/uberjar + PEERDIR+=$UBERJAR_RESOURCE_PEERDIR + } + + when($JAVA_YNDEXING == "yes") { + PEERDIR+=build/platform/java/kythe + _DO_JAVA_YNDEXING=&& $_JAVAC_RUN_HELPER($_JAVA_YNDEXING_CMD) && ${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/find_and_tar.py"} kindex.tar .kzip ${output;hide;tared:"kindex.tar"} + } + + when($ERROR_PRONE_VALUE) { + PEERDIR+=$ERROR_PRONE_PEERDIR + JAVAC_CMD=$ERROR_PRONE_JAVAC_CMD + } + + when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "16") { + JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS + JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS + } + + when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "17") { + JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS + JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS + } + + when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "18") { + JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS + JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS + } + + when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "19") { + JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS + JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS + } + + when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "20") { + JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS + JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS + } + + when($ERROR_PRONE_VALUE && $ERROR_PRONE_VERSION == "2.7.1") { + JAVAC_FLAGS_VALUE+=$ERROR_PRONE_2_7_1_FORCED_OPTS + JAVAC_OPTS+=$ERROR_PRONE_2_7_1_FORCED_OPTS + } + + when ($JAVA_ADD_DLLS_VALUE == "yes") { + CONSUME_NON_MANAGEABLE_PEERS=yes + _PACK_JNI=$_PACK_JNI_CMD + } + + when ($LINT_LEVEL_VALUE != "none") { + _MAKE_JSTYLE_FILE_LIST= && ${WRITER_PY} --file ${output;noauto:"lint-java.srclst"} -m --ya-start-command-file $LINT_JAVA_SOURCES --ya-end-command-file + } + + SET(MODULE_TYPE JAVA_LIBRARY) + ENABLE(YMAKE_JAVA_TEST) + _ADD_KOTLIN_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/all-kt-sources.txt REQUIREMENTS cpu:2) + _ADD_JAVA_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/lint-java.srclst::$(SOURCE_ROOT)) + _ADD_CLASSPATH_CLASH_CHECK() + JAVA_MODULE() +} + +# tag:java-specific +_SCRIPTGEN_FLAGS= +macro _GEN_JAVA_SCRIPT_IMPL(Out, Template, Props...) { + .CMD=$SCRIPTGEN_RESOURCE_GLOBAL/scriptgen --java $JDK_RESOURCE/bin/java --output ${output:Out} --template ${input:Template} ${_SCRIPTGEN_FLAGS} -D JAR_NAME=${REALPRJNAME}.jar -D CLASSPATH=${nopath;join;ext=.jar;pre="::":MANAGED_PEERS_CLOSURE} -D PROJECT_DIR=${MODDIR} -D JAR_BASENAME=${REALPRJNAME} $Props +} + +# tag:java-specific +_GEN_USERSCRIPTS= +macro _ADD_GEN_JAVA_SCRIPT(Out, Template, Props...) { + SET_APPEND(_GEN_USERSCRIPTS && \$_GEN_JAVA_SCRIPT_IMPL($Out $Template $Props)) +} + +# tag:java-specific +_PACK_JDK= + +# tag:java-specific +DO_GEN_JAVA_RUN_SH= +_SOURCE_JARS= +_SOURCE_JARS_CPLIST= +GEN_JAVA_RUN_SH=$SCRIPTGEN_RESOURCE_GLOBAL/scriptgen --java $JDK_RESOURCE/bin/java --output ${output:"run.sh"} -D GENERATE_DEFAULT_RUNNER=yes -D JAR_NAME=${REALPRJNAME}.jar -D CLASSPATH=${nopath;join;pre="::":MANAGED_PEERS_CLOSURE} -D PROJECT_DIR=${REALPRJNAME} -D JAR_BASENAME=${REALPRJNAME} +GEN_RUN_CP=${WRITER_PY} --file ${BINDIR}/run-bf.txt -Q -m --ya-start-command-file ${nopath;qe;pre=$REALPRJNAME/:MANAGED_PEERS_CLOSURE} --ya-end-command-file && ${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/run-bf.txt ${TARGET} +COLLECT_JAR_PROGRAM_CP=$FS_TOOLS link_or_copy_to_dir --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} ${ext=.so:MANAGED_PEERS_CLOSURE} ${ext=.dll:MANAGED_PEERS_CLOSURE} ${ext=.dylib:MANAGED_PEERS_CLOSURE} ${_SOURCE_JARS} --ya-end-command-file ${BINDIR}/${REALPRJNAME} ${hide;late_out;nopath;ext=.jar;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} +MAKE_JAR_PROGRAM_CPLST=${MAKE_JAVA_CLASSPATH_FILE} --from-args ${output;pre=$MODULE_PREFIX;suf=${MODULE_SUFFIX}.cplst:REALPRJNAME} --ya-start-command-file ${nopath;rootrel;ext=.jar;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${_SOURCE_JARS_CPLIST} --ya-end-command-file +TAR_CLASSPATH= && $YMAKE_PYTHON ${input:"build/scripts/find_and_tar.py"} ${output;pre=$MODULE_PREFIX;suf=.tar:REALPRJNAME} ${cwd;pre=$BINDIR/:REALPRJNAME} +DO_TAR_CLASSPATH= +LINK_JAR_PROGRAM=${hide:JAVA_FAKEID} $FS_TOOLS md ${BINDIR}/${REALPRJNAME} && $COLLECT_JAR_PROGRAM_CP && $DO_GEN_JAVA_RUN_SH && $GEN_RUN_CP && $MAKE_JAR_PROGRAM_CPLST $DO_TAR_CLASSPATH $_GEN_USERSCRIPTS $_PACK_JDK ${kv;hide:"p JP"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} + +# tag:java-specific +# UBERJAR program link command +LINK_UBERJAR_PROGRAM=${hide:JAVA_FAKEID} ${kv;hide:"p UJ"} ${MAKE_JAVA_CLASSPATH_FILE} --from-args ${output;pre=$MODULE_PREFIX;suf=${MODULE_SUFFIX}.cplst:REALPRJNAME} $TARGET \ + && $FS_TOOLS md ${BINDIR}/${REALPRJNAME} \ + && $FS_TOOLS link_or_copy ${BINDIR}/${REALPRJNAME}.jar $TARGET \ + && $FS_TOOLS link_or_copy_to_dir --ya-start-command-file ${BINDIR}/${REALPRJNAME}.jar ${ext=.so:MANAGED_PEERS_CLOSURE} ${ext=.dll:MANAGED_PEERS_CLOSURE} ${ext=.dylib:MANAGED_PEERS_CLOSURE} ${_SOURCE_JARS} --ya-end-command-file ${BINDIR}/${REALPRJNAME} ${hide;output;ext=.jar;pre=$BINDIR/$REALPRJNAME/:REALPRJNAME} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} \ + $DO_TAR_CLASSPATH \ + $_GEN_USERSCRIPTS \ + $_PACK_JDK + +# tag:java-specific +RUN_WITH_SOURCES=no +# TODO jbuild creates tar with all classpath deps by default and some projects rely on this. In ymake build this tar file creation is not needed and should be disabled by default in future +TARED_CLASSPATH=yes +_JAR_SRCS_CALLED=no + +# tag:java-specific +macro _MARK_JAVA_PROG_WITH_SOURCES(Args...) { + ENABLE(_JAR_SRCS_CALLED) +} + +# tag:java-specific +module _JAR_RUNNABLE: _COMPILABLE_JAR_BASE { + .FINAL_TARGET=yes + .CMD=LINK_JAR_PROGRAM + .SEM=IGNORED + .ALIASES=JAVA_SRCS=_MARK_JAVA_PROG_WITH_SOURCES GENERATE_SCRIPT=_YMAKE_GENERATE_SCRIPT + .ALLOWED=WITH_JDK + MODULE_SUFFIX=.run.cp.jar + CONSUME_NON_MANAGEABLE_PEERS=yes + + when ($RUN_WITH_SOURCES == "yes") { + _SOURCE_JARS=${ext=.jar;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE} ${hide;late_out;ext=.jar;nopath;pre=$BINDIR/$REALPRJNAME/;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE} + _SOURCE_JARS_CPLIST=${nopath;rootrel;ext=.jar;pre=$BINDIR/$REALPRJNAME/;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE} + } + + when ($TARED_CLASSPATH == "yes") { + DO_TAR_CLASSPATH=$TAR_CLASSPATH + } + + when ($DISABLE_SCRIPTGEN) { + DO_GEN_JAVA_RUN_SH= + } + otherwise { + DO_GEN_JAVA_RUN_SH=$GEN_JAVA_RUN_SH + PEERDIR+=build/platform/java/scriptgen + } + + when ($WITH_JDK_VALUE) { + _PACK_JDK= && ${YMAKE_PYTHON} ${input:"build/scripts/tar_directory.py"} ${output;tared:"jdk.tar"} $WITH_JDK_RESOURCE $WITH_JDK_RESOURCE + } + + when ($MAKE_UBERJAR_VALUE == "yes") { + LINK_JAR_PROGRAM=$LINK_UBERJAR_PROGRAM + DYNAMIC_LINK=no + _SCRIPTGEN_FLAGS=-D IS_UBERJAR=yes + } + otherwise { + _SCRIPTGEN_FLAGS=-D IS_UBERJAR=no + } + CHECK_PROVIDES() +} + +# tag:java-specific +multimodule JAR_PROGRAM { + module JAR_RUNNABLE: _JAR_RUNNABLE { + .ALLOWED=JAVA_RUNTIME_PEERDIR JAVA_RUNTIME_EXCLUDE + .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM + .ALIASES=EXCLUDE=_NOOP_MACRO PEERDIR=_NOOP_MACRO DEPENDENCY_MANAGEMENT=_NOOP_MACRO JAVA_RUNTIME_PEERDIR=PEERDIR JAVA_RUNTIME_EXCLUDE=EXCLUDE + .PEERDIRSELF=JAR_COMPILATION + + SET(MODULE_TYPE JAVA_PROGRAM) + } + module JAR_COMPILATION: JAR_LIBRARY { + .ALIASES=JAVA_RUNTIME_PEERDIR=_NOOP_MACRO JAVA_RUNTIME_EXCLUDE=_NOOP_MACRO + .FINAL_TARGET=no + SET(MODULE_TYPE JAVA_PROGRAM) + } +} + +# tag:java-specific +LINK_JAR_TEST=${hide:JAVA_FAKEID} ${WRITER_PY} --file ${BINDIR}/run-bf.txt -Q -m --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} --ya-end-command-file && ${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/run-bf.txt ${TARGET} ${kv;hide:"p JT"} +YMAKE_JAVA_TEST= +module _JAR_TEST: _COMPILABLE_JAR_BASE { + .FINAL_TARGET=yes + .CMD=LINK_JAR_TEST + .DEFAULT_NAME_GENERATOR=FullPath + CONSUME_NON_MANAGEABLE_PEERS=yes + + SET(MODULE_SUFFIX .test.cp.jar) + ENABLE(YMAKE_JAVA_TEST) + JAVA_TEST() + CHECK_PROVIDES() +} diff --git a/build/conf/perl.conf b/build/conf/perl.conf new file mode 100644 index 0000000000..757f919571 --- /dev/null +++ b/build/conf/perl.conf @@ -0,0 +1,75 @@ +# tag:perl-specific +when ($USE_LOCAL_TOOLS == "yes") { + PERL=$LOCAL_PERL + PERL_VERSION=$LOCAL_PERL_VERSION + PERL_PRIVLIB=$LOCAL_PERL_PRIVLIB + PERL_ARCHLIB=$LOCAL_PERL_ARCHLIB + when ($LOCAL_PERL_LIBS) { + PERL_LIBS=$LOCAL_PERL_LIBS + } +} +otherwise { + PERL=NO-PERL-SELECTED + PERL_VERSION=NO-PERL-SELECTED-VERSION + PERL_PRIVLIB=NO-PERL-SELECTED-PRIVLIB + PERL_ARCHLIB=NO-PERL-SELECTED-ARCHLIB +} + +# tag:perl-specific +PERL_LD_LIBRARY_PATH= +PERL_INCLUDE= +USE_PERL_SYSTEM=yes +when ($USE_PERL_SYSTEM == "yes") { + select ($PERL_SDK) { + "ubuntu-12" ? { + PERL_VERSION=5.14 + PERL_ROOT=${SYSTEM_PERL_514_RESOURCE_GLOBAL}/perl${PERL_VERSION} + PERL_LIB_ARCH= + } + "ubuntu-14" ? { + PERL_VERSION=5.18 + PERL_ROOT=${SYSTEM_PERL_518_RESOURCE_GLOBAL}/perl${PERL_VERSION} + PERL_LIB_ARCH= + } + "ubuntu-16" ? { + PERL_VERSION=5.22 + PERL_ROOT=${SYSTEM_PERL_522_RESOURCE_GLOBAL}/perl${PERL_VERSION} + PERL_LIB_ARCH=/x86_64-linux-gnu + } + "ubuntu-18" ? { + PERL_VERSION=5.26 + PERL_ROOT=${SYSTEM_PERL_526_RESOURCE_GLOBAL}/perl${PERL_VERSION} + PERL_LIB_ARCH=/x86_64-linux-gnu + } + "ubuntu-20" ? { + PERL_VERSION=5.30 + PERL_ROOT=${SYSTEM_PERL_530_RESOURCE_GLOBAL}/usr + PERL_LIB_ARCH=/x86_64-linux-gnu + } + } + + PERL=${PERL_ROOT}/bin/perl + PERL_ARCHLIB=${PERL_ROOT}/lib$PERL_LIB_ARCH/perl/${PERL_VERSION} + PERL_PRIVLIB=${PERL_ROOT}/share/perl/${PERL_VERSION} + PERL_LIBS=${PERL_ROOT}/lib${PERL_LIB_ARCH} + PERL_LD_LIBRARY_PATH=${env:"LD_LIBRARY_PATH=${PERL_ROOT}/lib"} + + # Perl searches it's modules in INC@ paths. They can not be sysrooted or disabled (at least I haven't found a way), + # so default Perl module directories should be prepended to perl command lines when using non-local perl. + PERL_INCLUDE=-I${PERL_ARCHLIB} -I${PERL_PRIVLIB} +} +PERL_DEFAULT_PEERDIR=yes + +# tag:perl-specific +PERLSUFFIX=-csuffix .cpp +PERLOUTPUT=${stdout;output:SRC.cpp} +when ($PERLC == "yes") { + PERLSUFFIX=-csuffix .c + PERLOUTPUT=${stdout;output:SRC.c} +} +XSUBPPFLAGS= +_XSTYPEMAPS= + +macro XSTYPEMAPS(Names...) { + SET_APPEND(_XSTYPEMAPS $Names) +} diff --git a/build/ymake.core.conf b/build/ymake.core.conf index 94ade1b13a..cb9810ad71 100644 --- a/build/ymake.core.conf +++ b/build/ymake.core.conf @@ -46,7 +46,7 @@ SO_OUTPUTS=no @import "${CONF_ROOT}/conf/ts/ts.conf" @import "${CONF_ROOT}/conf/docs.conf" @import "${CONF_ROOT}/conf/swig.conf" -@import "${CONF_ROOT}/conf/java.conf" +@import "${CONF_ROOT}/conf/perl.conf" @import "${CONF_ROOT}/conf/project_specific/other.conf" @import "${CONF_ROOT}/conf/project_specific/uservices.conf" @@ -227,83 +227,6 @@ when ($HAVE_MKL == "") { SFDL_TMP_OUT= ${output;tmp:SRC.tmp} -# tag:perl-specific -when ($USE_LOCAL_TOOLS == "yes") { - PERL=$LOCAL_PERL - PERL_VERSION=$LOCAL_PERL_VERSION - PERL_PRIVLIB=$LOCAL_PERL_PRIVLIB - PERL_ARCHLIB=$LOCAL_PERL_ARCHLIB - when ($LOCAL_PERL_LIBS) { - PERL_LIBS=$LOCAL_PERL_LIBS - } -} -otherwise { - PERL=NO-PERL-SELECTED - PERL_VERSION=NO-PERL-SELECTED-VERSION - PERL_PRIVLIB=NO-PERL-SELECTED-PRIVLIB - PERL_ARCHLIB=NO-PERL-SELECTED-ARCHLIB -} - -# tag:perl-specific -PERL_LD_LIBRARY_PATH= -PERL_INCLUDE= -USE_PERL_SYSTEM=yes -when ($USE_PERL_SYSTEM == "yes") { - select ($PERL_SDK) { - "ubuntu-12" ? { - PERL_VERSION=5.14 - PERL_ROOT=${SYSTEM_PERL_514_RESOURCE_GLOBAL}/perl${PERL_VERSION} - PERL_LIB_ARCH= - } - "ubuntu-14" ? { - PERL_VERSION=5.18 - PERL_ROOT=${SYSTEM_PERL_518_RESOURCE_GLOBAL}/perl${PERL_VERSION} - PERL_LIB_ARCH= - } - "ubuntu-16" ? { - PERL_VERSION=5.22 - PERL_ROOT=${SYSTEM_PERL_522_RESOURCE_GLOBAL}/perl${PERL_VERSION} - PERL_LIB_ARCH=/x86_64-linux-gnu - } - "ubuntu-18" ? { - PERL_VERSION=5.26 - PERL_ROOT=${SYSTEM_PERL_526_RESOURCE_GLOBAL}/perl${PERL_VERSION} - PERL_LIB_ARCH=/x86_64-linux-gnu - } - "ubuntu-20" ? { - PERL_VERSION=5.30 - PERL_ROOT=${SYSTEM_PERL_530_RESOURCE_GLOBAL}/usr - PERL_LIB_ARCH=/x86_64-linux-gnu - } - } - - PERL=${PERL_ROOT}/bin/perl - PERL_ARCHLIB=${PERL_ROOT}/lib$PERL_LIB_ARCH/perl/${PERL_VERSION} - PERL_PRIVLIB=${PERL_ROOT}/share/perl/${PERL_VERSION} - PERL_LIBS=${PERL_ROOT}/lib${PERL_LIB_ARCH} - PERL_LD_LIBRARY_PATH=${env:"LD_LIBRARY_PATH=${PERL_ROOT}/lib"} - - # Perl searches it's modules in INC@ paths. They can not be sysrooted or disabled (at least I haven't found a way), - # so default Perl module directories should be prepended to perl command lines when using non-local perl. - PERL_INCLUDE=-I${PERL_ARCHLIB} -I${PERL_PRIVLIB} -} -PERL_DEFAULT_PEERDIR=yes - -# tag:perl-specific -PERLSUFFIX=-csuffix .cpp -PERLOUTPUT=${stdout;output:SRC.cpp} -when ($PERLC == "yes") { - PERLSUFFIX=-csuffix .c - PERLOUTPUT=${stdout;output:SRC.c} -} -XSUBPPFLAGS= -_XSTYPEMAPS= - -macro XSTYPEMAPS(Names...) { - SET_APPEND(_XSTYPEMAPS $Names) -} - - # tag:tool-specific ARCH_TOOL=${tool:"tools/archiver"} @@ -3469,816 +3392,7 @@ macro _SRCS_NO_GLOBAL(GLOBAL[], FILES...) { SRCS($GLOBAL $FILES) } -# tag:java-specific -JAVA_VCS_MF_ARG= -COMPILE_JAVA_MF=${hide:JAVA_FAKEID} $COMPILE_JAVA $MAVEN_EXPORT_CMD - -# tag:java-specific -when ($EXT_JAVA_VCS_INFO == "yes") { - JAVA_VCS_MF_ARG=--vcs-mf $VCS_JAVA - COMPILE_JAVA_MF=${hide:JAVA_FAKEID} $GENERATE_VCS_JAVA_INFO_NODEP && $COMPILE_JAVA $MAVEN_EXPORT_CMD -} - -# tag:java-specific -EXT_JAVA_VCS_INFO=no -### @usage: EMBED_JAVA_VCS_INFO() -### -### Embed manifest with vcs info into `EXTERNAL_JAVA_LIBRARY` -### By default this is disabled. -macro EMBED_JAVA_VCS_INFO() { - .SEM=add_vcs_info_to_mf ${hide;output:"VcsInfoMfDummy.java"} - ENABLE(EXT_JAVA_VCS_INFO) -} - -# tag:java-specific tag:internal -### @usage: EXTERNAL_JAVA_LIBRARY() #internal -### -### EXTERNAL_JAVA_LIBRARY() is a module for creating a .jar file using non-Java code (generators etc.) -### Unlike regular JAVA_LIBRARY this module doesn't produce .pom file, so it cannot be exported to Maven itself. -### PEERDIR it from JAVA_LIBRARY or JAVA_PROGRAM for export to Maven. -module EXTERNAL_JAVA_LIBRARY: _BASE_UNIT { - .EXTS=.jsrc .java .jar .mf - .NODE_TYPE=Bundle - .CMD=COMPILE_JAVA_MF - # TODO(YMAKE-27) all contribs involved into opensource export must be JAVA_CONTRIB modules - # and this module must not be intended for export. Such hange will break JBUILD and thus is - # blocked on YMAKE-27 - .SEM=JAVA_CONTRIB_SEM - .PEERDIR_POLICY=as_build_from - .FINAL_TARGET=no - .ALIASES=SRCS=_SRCS_NO_GLOBAL - .ALLOWED=EMBED_JAVA_VCS_INFO - .RESTRICTED=EXTERNAL_JAR - .GLOBAL=MAVEN_EXPORT_COORDS EXPORT_GRADLE_PROJECT_COORDS - - PEERDIR(build/platform/java/jdk) - PEERDIR+=$JDK_RESOURCE_PEERDIR $EXTERNAL_JAVA_EXTRA_PEERDIR - when ($KOTLIN_PROTO == "yes") { - PEERDIR+=build/platform/java/kotlin contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${KOTLIN_VERSION} - } - - when ($MAVEN_EXPORT == "yes") { - when ($MAVEN_DEPLOY == "yes") { - PEERDIR+=build/external_resources/maven - MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM && $MAVEN_DEPLOY_CMD - } - otherwise { - MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM - } - MAVEN_EXPORT_COORDS_GLOBAL=$MAVEN_EXPORT_GOUP_ID:${MODULE_PREFIX}${REALPRJNAME}:${MAVEN_EXPORT_VERSION}: - } - - PEERDIR_TAGS=JAVA_PROTO JAVA_FBS JAVA_IDL PACKAGE_UNION - HAS_MANAGEABLE_PEERS=yes - DYNAMIC_LINK=yes - MACRO_ALIAS(PROTO_CMD _JAVA_PROTO_CMD) - MACRO_ALIAS(EVLOG_CMD _JAVA_EVLOG_CMD) - MACRO_ALIAS(FBS_CMD _JAVA_FLATC_CMD) - - when ($PACKAGE_PREFIX) { - PACKAGE_PREFIX_ARGS=--package-prefix=$PACKAGE_PREFIX - } - - DISABLE(NEED_PLATFORM_PEERDIRS) - NO_PLATFORM() - SET(MODULE_SUFFIX .jar) - SET(MODULE_LANG JAVA) - - _WHEN_EXPORT_GRADLE() -} - -# tag:java-specific -ALL_JAR_SOURCES= -LINT_JAVA_SOURCES= -ALL_SRCDIRS= -LINK_JAR_RESOURCES= -LINK_JAR_JSOURCES= -JAR_GEN_SRCS= -JAR_GEN_JSRCS= -macro _JAR_SRCS(SRCDIR=".", PACKAGE_PREFIX="", EXCLUDE[], FILES[], RESOURCES?"yes":"no", Globs...) { - _CHECK_JAVA_SRCDIR($SRCDIR) - SET_APPEND(ALL_SRCDIRS $SRCDIR) - SET(VAR_SALT $SRCDIR $Globs $EXCLUDE $PACKAGE_PREFIX $RESOURCES $FILES) - SET(JAR_SRCS_GLOB uniq_${hash:VAR_SALT}) - _LATE_GLOB(${JAR_SRCS_GLOB} ${pre=${SRCDIR}/:Globs} EXCLUDE ${EXCLUDE}) - SET_APPEND(LINT_JAVA_SOURCES \${input;rootrel;ext=.java:${JAR_SRCS_GLOB}}) - SET_APPEND(ALL_JAR_SOURCES --jsources ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt --resources ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt --srcdir ${quo:SRCDIR} \${input:${JAR_SRCS_GLOB}} ${pre=\$\{input\:\";suf=\"\}:FILES}) - _FILL_JAR_COPY_RESOURCES_CMD(LINK_JAR_RESOURCES ${quo:SRCDIR} ${BINDIR}/cls ${PACKAGE_PREFIX} ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt) - _FILL_JAR_COPY_RESOURCES_CMD(LINK_JAR_JSOURCES ${quo:SRCDIR} ${BINDIR}/src ${PACKAGE_PREFIX} ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt) - _FILL_JAR_GEN_SRCS(JAR_GEN_SRCS JAR $SRCDIR ${BINDIR}/cls ${BINDIR}/all-java.srclst $KT_SRCLIST ${BINDIR}/misc/all-gr-sources.txt ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt $Globs EXCLUDE $EXCLUDE) - _FILL_JAR_GEN_SRCS(JAR_GEN_JSRCS SRC_JAR $SRCDIR ${BINDIR}/cls ${BINDIR}/all-java.srclst $KT_SRCLIST ${BINDIR}/misc/all-gr-sources.txt ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt $Globs EXCLUDE $EXCLUDE) -} - -macro IDEA_JAR_SRCS(Args...) { - _JAR_SRCS($Args) - SET_APPEND(JAVA_SRCS_VALUE $ARGS_DELIM $Args) -} - -macro _HASH_HELPER(Args...) { - .CMD=${hash:Args} - .SEM=${hash:Args} -} - -macro _GENTAR_HELPER(OUT_DIR[], Args...) { - .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/autotar_gendirs.py"} --pack ${OUT_DIR} --outs ${output;tared;suf=.$_HASH_HELPER($Args).gentar:OUT_DIR} ${kv;hide:"tared_kind nodir"} -} - -# tag:java-specific -RUN_JAR_PROG_CP_PRE=@ -RUN_JAR_PROG_CP_SUF=.cplst -when($JDK_VERSION == "8") { - RUN_JAR_PROG_CP_PRE= - RUN_JAR_PROG_CP_SUF= -} - -# tag:java-specific -JDK_LATEST_VERSION=19 -JDK_LATEST_PEERDIR=build/platform/java/jdk/jdk${JDK_LATEST_VERSION} - -# tag:java-specific -macro _DO_2_RUN_JAR_PROGRAM(IN_DIRS_VAR="uniq_", IN_DIRS_INPUTS[], IN{input}[], IN_NOPARSE{input}[], IN_DIR[], OUT_NOAUTO{output}[], OUT{output}[], TOOL{tool}[], OUT_DIR[], CLASSPATH[], ADD_SRCS_TO_CLASSPATH?"yes":"no", CWD="${ARCADIA_BUILD_ROOT}", STDOUT="", STDOUT_NOAUTO="", Args...) { - _LATE_GLOB(${IN_DIRS_VAR} ${suf=/**/*:IN_DIR}) - _CHECK_RUN_JAVA_PROG_CLASSPATH($CLASSPATH) - .PEERDIR=build/platform/java/jdk $JDK_RESOURCE_PEERDIR - .CMD=${kv;hide:"p RJ"} ${kv;hide:"pc blue"} ${hide:JAVA_FAKEID} ${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/mkdir.py"} ${OUT_DIR} && ${cwd:CWD} $YMAKE_PYTHON ${input:"build/scripts/setup_java_tmpdir.py"} $YMAKE_PYTHON ${input:"build/scripts/stdout2stderr.py"} ${pre=--file=:STDOUT} ${output;hide:STDOUT} ${pre=--file=:STDOUT_NOAUTO} ${output;hide;noauto:STDOUT_NOAUTO} $YMAKE_PYTHON ${input:"build/scripts/fix_java_command_file_cp.py"} --build-root ${ARCADIA_BUILD_ROOT} $JDK_RESOURCE/bin/java -Dfile.encoding=utf8 -classpath ${RUN_JAR_PROG_CP_PRE}${tool:CLASSPATH}${RUN_JAR_PROG_CP_SUF} ${Args} && $_GENTAR_HELPER($CLASSPATH $IN_DIR $IN $IN_NOPARSE $TOOL $Args OUT_DIR $OUT_DIR) ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output;noauto;hide:OUT_NOAUTO} ${output;hide:OUT} ${tool;hide:TOOL} ${IN_DIRS_INPUTS} -} - -# tag:java-specific -macro _DO_1_RUN_JAR_PROGRAM(IN_DIRS_VAR="uniq", Args...) { - _DO_2_RUN_JAR_PROGRAM($Args IN_DIRS_VAR $IN_DIRS_VAR IN_DIRS_INPUTS ${"$"}{input;hide:$IN_DIRS_VAR}) -} - -# tag:java-specific -macro RUN_JAVA_PROGRAM(Args...) { - _DO_1_RUN_JAR_PROGRAM($Args IN_DIRS_VAR uniq_${hash:Args}) -} - -# tag:java-specific -_JAR_ANN_PROCESSORS= -_JAR_ANN_PROC_OPT_PREFIX= -macro JAR_ANNOTATION_PROCESSOR(Classes...) { - SET_APPEND(_JAR_ANN_PROCESSORS $Classes) - SET(_JAR_ANN_PROC_OPT_PREFIX -processor) - - # for ya ide idea only - SET_APPEND(ANNOTATION_PROCESSOR_VALUE $ARGS_DELIM $Classes) -} - -# tag:java-specific -macro _JAR_ANN_PROC_OPTS(Classes...) { - .CMD=$_JAR_ANN_PROC_OPT_PREFIX ${join=,:Classes} -} - -# tag:java-specific -macro _NOOP_MACRO(Args...) { - ENABLE(UNUSED_MACRO) -} - -# tag:java-specific -module _JAR_BASE: _BARE_UNIT { - .NODE_TYPE=Bundle - .CMD=TOUCH_UNIT - .PEERDIR_POLICY=as_build_from - .FINAL_TARGET=no - .ALIASES=SRCS=_SRCS_NO_GLOBAL - .ALLOWED=EMBED_JAVA_VCS_INFO DEPENDENCY_MANAGEMENT EXCLUDE - .DEFAULT_NAME_GENERATOR=TwoDirNames - .RESTRICTED=WITH_JDK RESOURCE RESOURCE_FILES - .GLOBAL=EXPORT_GRADLE_PROJECT_COORDS - - PEERDIR_TAGS=JAVA_PROTO JAVA_FBS JAVA_IDL DLL JAR_COMPILATION __EMPTY__ - - HAS_MANAGEABLE_PEERS=yes - DYNAMIC_LINK=yes - MACRO_ALIAS(PROTO_CMD _JAVA_PROTO_CMD) - MACRO_ALIAS(EVLOG_CMD _JAVA_EVLOG_CMD) - MACRO_ALIAS(FBS_CMD _JAVA_FLATC_CMD) - - DISABLE(NEED_PLATFORM_PEERDIRS) - NO_PLATFORM() - VCS_JAVA=${suf=.__vcs_version__.mf:TARGET} - SET(MODULE_LANG JAVA) - - _WHEN_EXPORT_GRADLE() -} - -JAVA_CONTRIB_PROXY_SEM=IGNORED -# tag:java-specific -module JAVA_CONTRIB_PROXY: _JAR_BASE { - .SEM=JAVA_CONTRIB_PROXY_SEM -} - -# tag:java-specific -macro _FETCH_CONTRIB(Id, Out, SBR="sbr:") { - .CMD=${hide:SANDBOX_FAKEID} ${cwd:BINDIR} ${resource;pre=$SBR:Id} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_sandbox.py"} --resource-file $(RESOURCE_ROOT)/sbr/$Id/resource --resource-id $Id --copy-to ${output:Out} ${input;hide:"build/scripts/fetch_from.py"} ${requirements;hide:"network:full"} ${kv;hide:"p SB"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"} - ADD_CHECK(check.resource $Id) -} - -# tag:java-specific -LOCAL_JAR_PATH= -LOCAL_SOURCES_JAR_PATH= -JAR_RESOURCE_ID= -SRC_RESOURCE_ID= -FETCH_SRCS_JAR= -FETCH_TARGET_JAR= -FETCH_CONTRIB_JAR=${hide:JAVA_FAKEID} $FETCH_TARGET_JAR $FETCH_SRCS_JAR - -# tag:java-specific -macro JAR_RESOURCE(Id) { - SET(JAR_RESOURCE_ID $Id) -} - -# tag:java-specific -macro SRC_RESOURCE(Id) { - SET(SRC_RESOURCE_ID $Id) -} - -# tag:java-specific -macro LOCAL_JAR(File) { - SET(LOCAL_JAR_PATH $File) -} - -# tag:java-specific -macro LOCAL_SOURCES_JAR(File) { - SET(LOCAL_SOURCES_JAR_PATH $File) -} - -JAVA_CONTRIB_SEM= \ - consumer_classpath $EXPORT_GRADLE_PROJECT_COORDS ${hide:TARGET} ${hide:AUTO_INPUT} && \ - peers_closure $MANAGED_PEERS_CLOSURE && \ - peers_closure_coords $EXPORT_GRADLE_PROJECT_COORDS_GLOBAL && \ - IGNORED - -# tag:java-specific -module JAVA_CONTRIB: _JAR_BASE { - .CMD=FETCH_CONTRIB_JAR - .SEM=JAVA_CONTRIB_SEM - .FINAL_TARGET=yes - .GLOBAL=MAVEN_EXPORT_COORDS EXPORT_GRADLE_PROJECT_COORDS - - when ($JAR_RESOURCE_ID) { - FETCH_TARGET_JAR= && $_FETCH_CONTRIB($JAR_RESOURCE_ID ${BINDIR}/${MODULE_PREFIX}${REALPRJNAME}${MODULE_SUFFIX}) - } - otherwise { - when ($LOCAL_JAR_PATH) { - FETCH_TARGET_JAR= && $FS_TOOLS copy ${input:LOCAL_JAR_PATH} $TARGET - } - otherwise { - FETCH_TARGET_JAR= && $GENERATE_VCS_JAVA_INFO_NODEP && ${cwd:BINDIR} $JDK_RESOURCE/bin/jar cfvm $TARGET $VCS_JAVA . - PEERDIR+=build/platform/java/jdk - PEERDIR+=$JDK_RESOURCE_PEERDIR - } - } - when ($SRC_RESOURCE_ID) { - FETCH_SRCS_JAR= && $_FETCH_CONTRIB($SRC_RESOURCE_ID ${BINDIR}/${REALPRJNAME}-sources.jar) - } - otherwise { - when ($LOCAL_SOURCES_JAR_PATH) { - FETCH_SRCS_JAR= && $FS_TOOLS copy ${input:LOCAL_SOURCES_JAR_PATH} {output;pre=${BINDIR}/;suf=-sources.jar:REALPRJNAME} - } - otherwise { - FETCH_SRCS_JAR= && $GENERATE_VCS_JAVA_INFO_NODEP && $FS_TOOLS md ${BINDIR}/fake-src && ${cwd;suf=/fake-src:BINDIR} $JDK_RESOURCE/bin/jar cfvm ${output;pre=${BINDIR}/;suf=-sources.jar:REALPRJNAME} $VCS_JAVA . - PEERDIR+=build/platform/java/jdk - PEERDIR+=$JDK_RESOURCE_PEERDIR - } - } - when ($MAVEN_EXPORT == "yes") { - _MAKEFILE_INCLUDE_LIKE_DEPS+=pom.xml - FETCH_CONTRIB_JAR+= && $MAVEN_EXPORT_GEN_DEPLST - } - - SET(MODULE_SUFFIX .jar) - _SETUP_MAVEN_EXPORT_COORDS_IF_NEED($MODDIR) -} - -MAKE_JAVA_CLASSPATH_FILE=$YMAKE_PYTHON ${input:"build/scripts/make_java_classpath_file.py"} ${input;hide:"build/scripts/process_command_files.py"} - -# tag:kotlin-specific -KOTLINC_OPTS_VALUE= - -# tag:kotlin-specific -KT_SRCLIST=${BINDIR}/misc/all-kt-sources.txt -KT_SRSCLIST_FLAG=--kotlin $KT_SRCLIST -KT_CLASSES_DIR=${BINDIR}/kt_cls -KT_CLASSPATH=${BINDIR}/kt_cp.txt -COLLECT_KT_CLASSPATH=${WRITER_PY} --file ${BINDIR}/kt_bfg.txt -m --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} --ya-end-command-file -LINK_KT_CLASSPATH=${MAKE_JAVA_CLASSPATH_FILE} ${BINDIR}/kt_bfg.txt $KT_CLASSPATH && $FS_TOOLS md $KT_CLASSES_DIR -COMPILE_KT= \ - ${cwd:ARCADIA_BUILD_ROOT} ${env:"LC_ALL=en_US.UTF-8"} $YMAKE_PYTHON ${input:"build/scripts/with_pathsep_resolve.py"} $YMAKE_PYTHON ${input:"build/scripts/run_javac.py"} --kotlin --sources-list $KT_SRCLIST \ - $JDK_RESOURCE/bin/java -jar $KOTLIN_COMPILER_RESOURCE_GLOBAL/kotlin-compiler.jar -no-stdlib -module-name $REALPRJNAME -jvm-target ${KOTLIN_JVM_TARGET} \ - @$KT_SRCLIST -classpath @$KT_CLASSPATH $KOTLINC_FLAGS_VALUE -d $KT_CLASSES_DIR $KOTLINC_OPTS_VALUE -ALL_KT_COMMANDS= -KT_CLASSPATH_ITEM= - -# tag:kotlin-specific -KT_KAPT_SOURCES_DIR=${BINDIR}/kapt_gen_src -KT_KAPT_STUBS_DIR=${BINDIR}/kapt_gen_stubs -KT_KAPT_AP_CLASSPATH= -KT_KAPT_PLUGIN_OPTS=-P plugin:org.jetbrains.kotlin.kapt3:sources=${KT_KAPT_SOURCES_DIR} -P plugin:org.jetbrains.kotlin.kapt3:classes=${KT_CLASSES_DIR} -P plugin:org.jetbrains.kotlin.kapt3:stubs=${KT_KAPT_STUBS_DIR} -P plugin:org.jetbrains.kotlin.kapt3:aptMode=stubsAndApt -### @usage: KAPT_OPTS(opts...) -### -### Used to specify annotation processor qualified class names. -### If specified multiple times, only last specification is used. -macro KAPT_OPTS(Args...) { - SET_APPEND(KT_KAPT_PLUGIN_OPTS ${pre=-P :Args}) -} -### @usage: KAPT_ANNOTATION_PROCESSOR(processors...) -### -### Used to specify annotation processor qualified class names. -### If specified multiple times, only last specification is used. -macro KAPT_ANNOTATION_PROCESSOR(Args...) { - KAPT_OPTS(${pre="plugin:org.jetbrains.kotlin.kapt3:processors=":Args}) -} -### @usage: KAPT_ANNOTATION_PROCESSOR_CLASSPATH(jars...) -### -### Used to specify classpath for annotation processors. -### If specified multiple times, all specifications are used. -macro KAPT_ANNOTATION_PROCESSOR_CLASSPATH(Args...) { - PEERDIR($Args) - SET_APPEND(KT_KAPT_AP_CLASSPATH $Args) -} - -# tag:java-specific -JAVAC_CMD=$JDK_RESOURCE/bin/javac -ERROR_PRONE_JAVAC_CMD=${YMAKE_PYTHON} ${input:"build/scripts/build_java_with_error_prone2.py"} $JDK_RESOURCE/bin/java $JDK_RESOURCE/bin/javac $ERROR_PRONE_RESOURCE/error_prone.jar - -# tag:java-specific tag:codenav -JAVA_YNDEXING=no - -# tag:java-specific -when ($USE_SYSTEM_KYTHE) { - KYTHE_RESOURCE=$USE_SYSTEM_KYTHE -} -otherwise { - KYTHE_RESOURCE=$KYTHE_RESOURCE_GLOBAL -} - -# tag:java-specific tag:codenav -_JAVA_YNDEXING_CMD=$YMAKE_PYTHON ${input:"build/scripts/build_java_codenav_index.py"} $TARGET $ARCADIA_BUILD_ROOT $ARCADIA_ROOT ${BINDIR}/all-java.srclst $JDK_RESOURCE/bin/java -jar $KYTHE_RESOURCE/kythe/extractors/javac_extractor.jar -_DO_JAVA_YNDEXING= - -# tag:java-specific -SOURCES_JAR=no -when ($BUILD_TYPE == "DEBUG" && $NO_DEBUGINFO != "yes") { - SOURCES_JAR=yes -} - -_PACK_SRC_JAR_IMPL=&& $FS_TOOLS md ${BINDIR}/src $JAR_GEN_JSRCS $LINK_JAR_JSOURCES && ${cwd;suf=/src:BINDIR} $JDK_RESOURCE/bin/jar cfvm ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME} $VCS_JAVA . -_PACK_SRC_JAR= - -# tag:java-specific -_PACK_JNI= -_PACK_JNI_CMD= && $FS_TOOLS link_or_copy_to_dir --ya-start-command-file ${ext=.so:MANAGED_PEERS_CLOSURE} ${ext=.dll:MANAGED_PEERS_CLOSURE} ${ext=.dylib:MANAGED_PEERS_CLOSURE} --ya-end-command-file ${BINDIR}/cls - -# tag:java-specific -_MAKE_JSTYLE_FILE_LIST= - -# tag:java-specific -_LINK_UBERJAR= -_UBERJAR_SELF= -_DO_LINK_UBERJAR= && $JDK_RESOURCE/bin/java -cp $UBERJAR_RESOURCE/devtools-java_shader.jar ru.yandex.devtools.emigrante.Main --out-jar $TARGET $_UBERJAR_SELF ${ext=.jar;pre=--jar :MANAGED_PEERS_CLOSURE} ${UBERJAR_PREFIX_FLAG} ${UBERJAR_HIDE_EXCLUDE_FLAGS} $UBERJAR_PATH_EXCLUDES ${UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG} ${UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS} ${UBERJAR_APPENDING_TRANSFORMER_FLAGS} ${UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG} \ - && $YMAKE_PYTHON ${input:"build/scripts/mkdir.py"} $BINDIR/_empty/META-INF \ - && $YMAKE_PYTHON ${input:"build/scripts/touch.py"} $BINDIR/_empty/META-INF/MANIFEST.MF \ - && $UPDATE_VCS_JAVA_INFO_NODEP($TARGET) \ - && ${cwd;suf=/_empty:BINDIR} ${JDK_RESOURCE}/bin/jar ufv ${TARGET} META-INF/MANIFEST.MF \ - && $JDK_RESOURCE/bin/jar ufvm $TARGET $VCS_JAVA - -# tag:java-specific -macro _PACK_JAR_HELPER(Out) { - .CMD=${cwd;suf=/cls:BINDIR} ${env:"LC_ALL=en_US.UTF-8"} $JDK_RESOURCE/bin/jar cfvm $Out $VCS_JAVA . -} - -# tag:java-specific -macro _JAVAC_RUN_HELPER(JAVAC_CMD_WITH_ARGS...) { - .CMD=${cwd:ARCADIA_BUILD_ROOT} ${env:"LC_ALL=en_US.UTF-8"} $YMAKE_PYTHON ${input:"build/scripts/with_pathsep_resolve.py"} $YMAKE_PYTHON ${input:"build/scripts/setup_java_tmpdir.py"} $YMAKE_PYTHON ${input:"build/scripts/run_javac.py"} --sources-list ${BINDIR}/all-java.srclst ${JAVAC_CMD_WITH_ARGS} @${BINDIR}/all-java.srclst -classpath ${ARCADIA_BUILD_ROOT}/bfg.jar -Xpkginfo:always ${JAVAC_OPTS} $_JAR_ANN_PROC_OPTS($_JAR_ANN_PROCESSORS) -d ${BINDIR}/cls -g -encoding UTF-8 -} -macro _ADD_HIDDEN_INPUTS(Inputs...) { - .CMD=${input;hide:Inputs} -} - -# tag:java-specific -ERROR_PRONE_JDK16_ADD_OPENS=-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED -ERROR_PRONE_2_7_1_FORCED_OPTS=-Xep:InlineMeInliner:OFF -Xep:SameNameButDifferent:OFF - -# tag:java-specific -macro _ADD_OPTS_IF_NON_EMPTY(Opt, Args...) { - .CMD=${pre=$Opt :Args} -} -macro _ADD_GEN_POM_FROM_COORD_FILES_ARGS(Deps...) { - .CMD=${pre=--deps-coords ;ext=.jar;suf=.mvn_coords:Deps} -} -MAVEN_EXPORT_OUT_DIR_FLAG=$_ADD_OPTS_IF_NON_EMPTY(--output-dir ${MAVEN_EXPORT_OUT_DIR}) -MAVEN_EXPORT_SOURCE_DIRS=$_ADD_OPTS_IF_NON_EMPTY(--source-dirs ${ALL_SRCDIRS}) -MAVEN_EXPORT_DEPS_COORS=$_ADD_GEN_POM_FROM_COORD_FILES_ARGS(${MANAGED_PEERS_CLOSURE}) -MAVEN_EXPORT_OUT_DIR= - -MAVEN_EXPORT=no -MAVEN_DEPLOY=no -MAVEN_DEPLOY_SOURCES= -MAVEN_EXPORT_VERSION={vcs_revision} -MAVEN_EXPORT_GEN_DEPLST= \ - $WRITER_PY \ - --file ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.mvn_coords:REALPRJNAME} \ - --ya-start-command-file -m ${pre=D=:MAVEN_EXPORT_COORDS_GLOBAL} ${pre=E=:EXCLUDED_MAVEN_EXPORT_COORDS_GLOBAL} --ya-end-command-file \ - ${hide:APPLIED_EXCLUDES} -MAVEN_EXPORT_GEN_POM=${kv;hide:"mvn_export yes"} \ - $YMAKE_PYTHON ${input:"build/scripts/generate_pom.py"} \ - --from-coord-files \ - --vcs-info $(VCS)/vcs.json \ - --target-path $MODDIR \ - $MAVEN_EXPORT_SOURCE_DIRS \ - $MAVEN_EXPORT_DEPS_COORS \ - $MAVEN_EXPORT_OUT_DIR_FLAG \ - --target-coords ${suf=.mvn_coords:TARGET} \ - --pom-path ${output:"pom.xml"} - -MAVEN_DEPLOY_CMD=$YMAKE_PYTHON ${input:"build/scripts/stdout2stderr.py"} $MAVEN_BIN \ - deploy:deploy-file -DpomFile=$BINDIR/pom.xml \ - -Dfile=$TARGET -DrepositoryId=$MAVEN_REPO_ID -Durl=$MAVEN_REPO_URL -Djava.net.preferIPv4Addresses=false -Djava.net.preferIPv6Addresses=true \ - ${MAVEN_DEPLOY_SOURCES} \ - $_ADD_OPTS_IF_NON_EMPTY(-gs $MAVEN_EXPORT_SETTINGS) \ - $_ADD_OPTS_IF_NON_EMPTY(-s $MAVEN_EXPORT_SETTINGS) -MAVEN_EXPORT_CMD= - -# tag:java-specific -JAVA_COVERAGE_SRCLIST_FLAG=--coverage ${output;pre=${MODULE_PREFIX};suf=.cpsf:REALPRJNAME} --source-root ${ARCADIA_ROOT} -JAVA_COVERAGE_SRCLIST= -PREPARE_JAVA_BUILD_DIRS=$FS_TOOLS md ${BINDIR}/cls && $FS_TOOLS md ${BINDIR}/misc -EXTRACT_GENDIRS=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/autotar_gendirs.py"} --unpack --ext .gentar ${ext=.gentar:AUTO_INPUT} -COLLECT_JAVA_SRCLIST=${YMAKE_PYTHON} ${input:"build/scripts/make_java_srclists.py"} ${input;hide:"build/scripts/process_command_files.py"} ${input;hide:"build/scripts/java_pack_to_file.py"} --moddir ${CURDIR} --java ${BINDIR}/all-java.srclst ${KT_SRSCLIST} ${JAVA_COVERAGE_SRCLIST} --ya-start-command-file ${ALL_JAR_SOURCES} ${ext=.java:AUTO_INPUT} ${ext=.kt:AUTO_INPUT} --ya-end-command-file -COLLECT_CLASSPATH=${WRITER_PY} --file ${BINDIR}/bfg.txt -m --ya-start-command-file ${rootrel:MANAGED_PEERS_CLOSURE} $KT_CLASSPATH_ITEM --ya-end-command-file -LINK_CLASSPATH=${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/bfg.txt ${ARCADIA_BUILD_ROOT}/bfg.jar -COMPILE_JAVA_SRCLIST=$_JAVAC_RUN_HELPER($JAVAC_CMD) -PACK_JAR=$_PACK_JAR_HELPER($TARGET) -# NOTE: No && before LINK_JAR_RESOURCES, ALL_KT_COMMANDS and JAR_GEN_SRCS needed since those vars either empty or starts with && -LINK_JAR=${hide:JAVA_FAKEID} ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} ${requirements;hide:"cpu:2"} \ - $PREPARE_JAVA_BUILD_DIRS \ - && $EXTRACT_GENDIRS \ - && $COLLECT_JAVA_SRCLIST \ - $JAR_GEN_SRCS \ - $ALL_KT_COMMANDS \ - && $COLLECT_CLASSPATH \ - && $LINK_CLASSPATH \ - && $COMPILE_JAVA_SRCLIST \ - $LINK_JAR_RESOURCES \ - && ${cwd;suf=/cls:BINDIR} $GENERATE_VCS_JAVA_INFO_NODEP . \ - $_PACK_SRC_JAR \ - $_PACK_JNI \ - && $PACK_JAR \ - $_DO_JAVA_YNDEXING \ - $_MAKE_JSTYLE_FILE_LIST \ - $_LINK_UBERJAR \ - $MAVEN_EXPORT_CMD \ - $_ADD_HIDDEN_INPUTS($JAVA_EXTERNAL_DEPENDENCIES_VALUE) - -# tag:java-specific -_EXT_SRC_JAR= -_EXT_JAR= -_COPY_EXT_SRC_JAR= && $FS_TOOLS md ${BINDIR}/empty && ${cwd;suf=/empty:BINDIR} $JDK_RESOURCE/bin/jar cfvM ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME} . -_DO_USE_EXT_JAR=${hide:JAVA_FAKEID} $FS_TOOLS copy ${input:_EXT_JAR} $TARGET $_COPY_EXT_SRC_JAR $MAVEN_EXPORT_CMD -_DO_COPY_EXT_SRC_JAR= && $FS_TOOLS copy $_EXT_SRC_JAR ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME} -macro JAVA_RESOURCE(JAR, SOURCES="") { - SET(_EXT_SRC_JAR $SOURCES) - SET(_EXT_JAR $JAR) -} - -# tag:java-specific tag:fbs -JAVA_FLATBUFFERS_VERSION = 2.0.0 - -# tag:java-specific -module _COMPILABLE_JAR_BASE : _JAR_BASE { - # flatbuffers-java - DEPENDENCY_MANAGEMENT(contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION}) - CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/flatbuffers/flatbuffers-java EXCEPT contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION}) - - # protobuf-java - DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION}) - CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-java EXCEPT contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION}) - - # protobuf-javalite - DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION}) - CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-javalite EXCEPT contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION}) - - # protobuf-java-util - DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java-util/${JAVA_PROTO_RUNTIME_VERSION}) - CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-java-util EXCEPT contrib/java/com/google/protobuf/protobuf-java-util/${JAVA_PROTO_RUNTIME_VERSION}) -} - -_JAR_MAIN_CLASS= -macro JAR_MAIN_CLASS(Class) { - SET(_JAR_MAIN_CLASS ${Class}) -} - -_JAR_MAIN_SEM= -_ADD_JAR_MAIN_SEM= && app_main_class ${_JAR_MAIN_CLASS} - -GRADLE_EXPORT_PUBLISHING=no -_GRADLE_EXPORT_PUBLISHING_SEM= -PUBLISH_MAVEN_VERSION=no -_DO_GRADLE_EXPORT_PUBLISHING_SEM= && publish True && publish_group $MAVEN_EXPORT_GOUP_ID && publish_version $PUBLISH_MAVEN_VERSION - -BUILD_JAR_SEM= \ - jar $MODDIR $REALPRJNAME ${hide:TARGET} ${hide:AUTO_INPUT} && \ - applied_excludes $EXCLUDED_EXPORT_GRADLE_PROJECT_COORDS_GLOBAL ${hide:APPLIED_EXCLUDES} && \ - excludes_rules $EXCLUDE_VALUE && \ - consumer_classpath $EXPORT_GRADLE_PROJECT_COORDS $_JAR_MAIN_SEM $_GRADLE_EXPORT_PUBLISHING_SEM - -### _EXPORT_GRADLE_TARGET_ATTR(NAME, VALUE...) -### -### Add target attribute `NAME` for .SEM if `VALUE` is non-empty -### ` && $Name $Value -macro _EXPORT_GRADLE_TARGET_ATTR(NAME, VALUE...) { - .SEM=${pre= && $NAME :VALUE} -} - -BUILD_PROTO_JAR_SEM= \ - jar_proto $MODDIR $REALPRJNAME ${hide:target} ${hide:AUTO_INPUT} && \ - consumer_classpath $EXPORT_GRADLE_PROJECT_COORDS $_EXPORT_GRADLE_TARGET_ATTR(proto_namespace $PROTO_NAMESPACE) $_EXPORT_GRADLE_TARGET_ATTR(proto_grpc ${ext=yes:_GRPC_ENABLED}) - -# tag:java-specific tag:internal -### @usage: JAR_LIBRARY() #internal -### -### Reimplementation of the JAVA_LIBRARY with ymake.core.conf and ymake based dependency management -module JAR_LIBRARY: _COMPILABLE_JAR_BASE { - .EXTS=.jsrc .java .jar .mf .gentar .kt - .CMD=LINK_JAR - .SEM=BUILD_JAR_SEM - .FINAL_TARGET=yes - .ALIASES=JAVA_SRCS=IDEA_JAR_SRCS ANNOTATION_PROCESSOR=JAR_ANNOTATION_PROCESSOR - .RESTRICTED=EXTERNAL_JAR - .GLOBAL=MAVEN_EXPORT_COORDS EXPORT_GRADLE_PROJECT_COORDS - MODULE_SUFFIX=.jar - - PEERDIR(build/platform/java/jdk) - PEERDIR+=$JDK_RESOURCE_PEERDIR - - when ($_EXT_SRC_JAR) { - _COPY_EXT_SRC_JAR=_DO_COPY_EXT_SRC_JAR - } - when ($_EXT_JAR) { - LINK_JAR=$_DO_USE_EXT_JAR - } - when ($OPENSOURCE_EXPORT == "no") { - BUILD_JAR_SEM=IGNORED - } - when ($_JAR_MAIN_CLASS) { - _JAR_MAIN_SEM=$_ADD_JAR_MAIN_SEM - } - when ($GRADLE_EXPORT_PUBLISHING == "yes") { - _GRADLE_EXPORT_PUBLISHING_SEM=$_DO_GRADLE_EXPORT_PUBLISHING_SEM - } - - # in the ideal world this statement must be under condition bellow - DEPENDENCY_MANAGEMENT(contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${KOTLIN_VERSION}) - when ($WITH_KOTLIN_VALUE) { - KT_SRSCLIST=$KT_SRSCLIST_FLAG - _MAKE_LINT_KT_FILES_LIST = $YMAKE_PYTHON ${input:"build/scripts/kt_copy.py"} $KT_SRCLIST ${output;noauto:"all-kt-sources.txt"} $(SOURCE_ROOT) $(BUILD_ROOT) - ALL_KT_COMMANDS=&& $COLLECT_KT_CLASSPATH && $LINK_KT_CLASSPATH - when ($WITH_KAPT_VALUE == "yes") { - # For Kapt usage see: https://kotlinlang.org/docs/kapt.html#using-in-cli - # See for kapt.kotlin.generated: https://github.com/JetBrains/kotlin/blob/master/plugins/kapt3/kapt3-cli/testData/integration/kotlinFileGeneration/build.txt - _KAPT_OPTS=-Xplugin=${tool:"contrib/java/org/jetbrains/kotlin/kotlin-annotation-processing/1.8.20"} $KT_KAPT_PLUGIN_OPTS - _RUN_KAPT=${YMAKE_PYTHON} ${input:"build/scripts/with_kapt_args.py"} ${pre=--ap-classpath :KT_KAPT_AP_CLASSPATH} -- $COMPILE_KT $_KAPT_OPTS - _APPEND_KAPT_GENERATED_SRCS=$YMAKE_PYTHON ${input:"build/scripts/resolve_java_srcs.py"} -d $KT_KAPT_SOURCES_DIR --include-patterns '**/*.java' '**/*.kt' --resolve-kotlin --append -s ${BINDIR}/all-java.srclst -k $KT_SRCLIST -r ${BINDIR}/not-used.txt - - ALL_KT_COMMANDS+=&& $_RUN_KAPT && $_APPEND_KAPT_GENERATED_SRCS - } - ALL_KT_COMMANDS+=&& $COMPILE_KT && $_MAKE_LINT_KT_FILES_LIST - LINK_JAR_RESOURCES+=&& $FS_TOOLS copy_all_files ${KT_CLASSES_DIR} ${BINDIR}/cls - PEERDIR+=build/platform/java/kotlin contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8 - when($WITH_KOTLINC_PLUGIN_ALLOPEN) { - KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-allopen-plugin.jar - } - when($WITH_KOTLINC_PLUGIN_LOMBOK) { - KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-lombok-plugin.jar - } - when($WITH_KOTLINC_PLUGIN_NOARG) { - KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-noarg-plugin.jar - } - when($WITH_KOTLINC_PLUGIN_SERIALIZATION) { - KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-serialization-plugin.jar - } - # Must be in sync with KT_CLASSES_DIR! - # There are problems in JDK13 with abs paths in classpath baked into jar file manifest. Using relative path - # here assumes that jar file with classpath for javac located in the $ARCADIA_BUILD_ROOT - KT_CLASSPATH_ITEM=$MODDIR/kt_cls - } - otherwise { - KT_SRSCLIST= - ALL_KT_COMMANDS= - KT_CLASSES= - } - - when ($MAVEN_EXPORT == "yes") { - when ($MAVEN_DEPLOY == "yes") { - PEERDIR+=build/external_resources/maven - MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM && $MAVEN_DEPLOY_CMD - } - otherwise { - MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM - } - MAVEN_EXPORT_COORDS_GLOBAL=$MAVEN_EXPORT_GOUP_ID:${MODULE_PREFIX}${REALPRJNAME}:${MAVEN_EXPORT_VERSION}: - } - - when ($SOURCES_JAR == "yes") { - _PACK_SRC_JAR=$_PACK_SRC_JAR_IMPL - MAVEN_DEPLOY_SOURCES=-Dsources=${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME} - } - - when ($JAVA_COVERAGE == "yes") { - JAVA_COVERAGE_SRCLIST=$JAVA_COVERAGE_SRCLIST_FLAG - } - - when ($MAKE_UBERJAR_VALUE == "yes") { - _LINK_UBERJAR=$_DO_LINK_UBERJAR - PACK_JAR=$_PACK_JAR_HELPER(${BINDIR}/${REALPRJNAME}.lib.jar) - # TODO: This condition is incorrect in case of autoinputs _UBERJAR_SELF should be empty only for - # modules without AUTO_INPUT and without JAVA_SRCS added inputs. - when($ALL_JAR_SOURCES) { - _UBERJAR_SELF=--jar ${BINDIR}/${REALPRJNAME}.lib.jar - } - PEERDIR+=build/platform/java/uberjar - PEERDIR+=$UBERJAR_RESOURCE_PEERDIR - } - - when($JAVA_YNDEXING == "yes") { - PEERDIR+=build/platform/java/kythe - _DO_JAVA_YNDEXING=&& $_JAVAC_RUN_HELPER($_JAVA_YNDEXING_CMD) && ${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/find_and_tar.py"} kindex.tar .kzip ${output;hide;tared:"kindex.tar"} - } - - when($ERROR_PRONE_VALUE) { - PEERDIR+=$ERROR_PRONE_PEERDIR - JAVAC_CMD=$ERROR_PRONE_JAVAC_CMD - } - - when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "16") { - JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS - JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS - } - - when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "17") { - JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS - JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS - } - - when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "18") { - JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS - JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS - } - - when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "19") { - JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS - JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS - } - - when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "20") { - JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS - JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS - } - - when($ERROR_PRONE_VALUE && $ERROR_PRONE_VERSION == "2.7.1") { - JAVAC_FLAGS_VALUE+=$ERROR_PRONE_2_7_1_FORCED_OPTS - JAVAC_OPTS+=$ERROR_PRONE_2_7_1_FORCED_OPTS - } - - when ($JAVA_ADD_DLLS_VALUE == "yes") { - CONSUME_NON_MANAGEABLE_PEERS=yes - _PACK_JNI=$_PACK_JNI_CMD - } - - when ($LINT_LEVEL_VALUE != "none") { - _MAKE_JSTYLE_FILE_LIST= && ${WRITER_PY} --file ${output;noauto:"lint-java.srclst"} -m --ya-start-command-file $LINT_JAVA_SOURCES --ya-end-command-file - } - - SET(MODULE_TYPE JAVA_LIBRARY) - ENABLE(YMAKE_JAVA_TEST) - _ADD_KOTLIN_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/all-kt-sources.txt REQUIREMENTS cpu:2) - _ADD_JAVA_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/lint-java.srclst::$(SOURCE_ROOT)) - _ADD_CLASSPATH_CLASH_CHECK() - JAVA_MODULE() -} - -# tag:java-specific -_SCRIPTGEN_FLAGS= -macro _GEN_JAVA_SCRIPT_IMPL(Out, Template, Props...) { - .CMD=$SCRIPTGEN_RESOURCE_GLOBAL/scriptgen --java $JDK_RESOURCE/bin/java --output ${output:Out} --template ${input:Template} ${_SCRIPTGEN_FLAGS} -D JAR_NAME=${REALPRJNAME}.jar -D CLASSPATH=${nopath;join;ext=.jar;pre="::":MANAGED_PEERS_CLOSURE} -D PROJECT_DIR=${MODDIR} -D JAR_BASENAME=${REALPRJNAME} $Props -} - -# tag:java-specific -_GEN_USERSCRIPTS= -macro _ADD_GEN_JAVA_SCRIPT(Out, Template, Props...) { - SET_APPEND(_GEN_USERSCRIPTS && \$_GEN_JAVA_SCRIPT_IMPL($Out $Template $Props)) -} - -# tag:java-specific -_PACK_JDK= - -# tag:java-specific -DO_GEN_JAVA_RUN_SH= -_SOURCE_JARS= -_SOURCE_JARS_CPLIST= -GEN_JAVA_RUN_SH=$SCRIPTGEN_RESOURCE_GLOBAL/scriptgen --java $JDK_RESOURCE/bin/java --output ${output:"run.sh"} -D GENERATE_DEFAULT_RUNNER=yes -D JAR_NAME=${REALPRJNAME}.jar -D CLASSPATH=${nopath;join;pre="::":MANAGED_PEERS_CLOSURE} -D PROJECT_DIR=${REALPRJNAME} -D JAR_BASENAME=${REALPRJNAME} -GEN_RUN_CP=${WRITER_PY} --file ${BINDIR}/run-bf.txt -Q -m --ya-start-command-file ${nopath;qe;pre=$REALPRJNAME/:MANAGED_PEERS_CLOSURE} --ya-end-command-file && ${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/run-bf.txt ${TARGET} -COLLECT_JAR_PROGRAM_CP=$FS_TOOLS link_or_copy_to_dir --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} ${ext=.so:MANAGED_PEERS_CLOSURE} ${ext=.dll:MANAGED_PEERS_CLOSURE} ${ext=.dylib:MANAGED_PEERS_CLOSURE} ${_SOURCE_JARS} --ya-end-command-file ${BINDIR}/${REALPRJNAME} ${hide;late_out;nopath;ext=.jar;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} -MAKE_JAR_PROGRAM_CPLST=${MAKE_JAVA_CLASSPATH_FILE} --from-args ${output;pre=$MODULE_PREFIX;suf=${MODULE_SUFFIX}.cplst:REALPRJNAME} --ya-start-command-file ${nopath;rootrel;ext=.jar;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${_SOURCE_JARS_CPLIST} --ya-end-command-file -TAR_CLASSPATH= && $YMAKE_PYTHON ${input:"build/scripts/find_and_tar.py"} ${output;pre=$MODULE_PREFIX;suf=.tar:REALPRJNAME} ${cwd;pre=$BINDIR/:REALPRJNAME} -DO_TAR_CLASSPATH= -LINK_JAR_PROGRAM=${hide:JAVA_FAKEID} $FS_TOOLS md ${BINDIR}/${REALPRJNAME} && $COLLECT_JAR_PROGRAM_CP && $DO_GEN_JAVA_RUN_SH && $GEN_RUN_CP && $MAKE_JAR_PROGRAM_CPLST $DO_TAR_CLASSPATH $_GEN_USERSCRIPTS $_PACK_JDK ${kv;hide:"p JP"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} - -# tag:java-specific -# UBERJAR program link command -LINK_UBERJAR_PROGRAM=${hide:JAVA_FAKEID} ${kv;hide:"p UJ"} ${MAKE_JAVA_CLASSPATH_FILE} --from-args ${output;pre=$MODULE_PREFIX;suf=${MODULE_SUFFIX}.cplst:REALPRJNAME} $TARGET \ - && $FS_TOOLS md ${BINDIR}/${REALPRJNAME} \ - && $FS_TOOLS link_or_copy ${BINDIR}/${REALPRJNAME}.jar $TARGET \ - && $FS_TOOLS link_or_copy_to_dir --ya-start-command-file ${BINDIR}/${REALPRJNAME}.jar ${ext=.so:MANAGED_PEERS_CLOSURE} ${ext=.dll:MANAGED_PEERS_CLOSURE} ${ext=.dylib:MANAGED_PEERS_CLOSURE} ${_SOURCE_JARS} --ya-end-command-file ${BINDIR}/${REALPRJNAME} ${hide;output;ext=.jar;pre=$BINDIR/$REALPRJNAME/:REALPRJNAME} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} \ - $DO_TAR_CLASSPATH \ - $_GEN_USERSCRIPTS \ - $_PACK_JDK - -# tag:java-specific -RUN_WITH_SOURCES=no -# TODO jbuild creates tar with all classpath deps by default and some projects rely on this. In ymake build this tar file creation is not needed and should be disabled by default in future -TARED_CLASSPATH=yes -_JAR_SRCS_CALLED=no - -# tag:java-specific -macro _MARK_JAVA_PROG_WITH_SOURCES(Args...) { - ENABLE(_JAR_SRCS_CALLED) -} - -# tag:java-specific -module _JAR_RUNNABLE: _COMPILABLE_JAR_BASE { - .FINAL_TARGET=yes - .CMD=LINK_JAR_PROGRAM - .SEM=IGNORED - .ALIASES=JAVA_SRCS=_MARK_JAVA_PROG_WITH_SOURCES GENERATE_SCRIPT=_YMAKE_GENERATE_SCRIPT - .ALLOWED=WITH_JDK - MODULE_SUFFIX=.run.cp.jar - CONSUME_NON_MANAGEABLE_PEERS=yes - - when ($RUN_WITH_SOURCES == "yes") { - _SOURCE_JARS=${ext=.jar;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE} ${hide;late_out;ext=.jar;nopath;pre=$BINDIR/$REALPRJNAME/;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE} - _SOURCE_JARS_CPLIST=${nopath;rootrel;ext=.jar;pre=$BINDIR/$REALPRJNAME/;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE} - } - - when ($TARED_CLASSPATH == "yes") { - DO_TAR_CLASSPATH=$TAR_CLASSPATH - } - - when ($DISABLE_SCRIPTGEN) { - DO_GEN_JAVA_RUN_SH= - } - otherwise { - DO_GEN_JAVA_RUN_SH=$GEN_JAVA_RUN_SH - PEERDIR+=build/platform/java/scriptgen - } - - when ($WITH_JDK_VALUE) { - _PACK_JDK= && ${YMAKE_PYTHON} ${input:"build/scripts/tar_directory.py"} ${output;tared:"jdk.tar"} $WITH_JDK_RESOURCE $WITH_JDK_RESOURCE - } - - when ($MAKE_UBERJAR_VALUE == "yes") { - LINK_JAR_PROGRAM=$LINK_UBERJAR_PROGRAM - DYNAMIC_LINK=no - _SCRIPTGEN_FLAGS=-D IS_UBERJAR=yes - } - otherwise { - _SCRIPTGEN_FLAGS=-D IS_UBERJAR=no - } - CHECK_PROVIDES() -} - -# tag:java-specific -multimodule JAR_PROGRAM { - module JAR_RUNNABLE: _JAR_RUNNABLE { - .ALLOWED=JAVA_RUNTIME_PEERDIR JAVA_RUNTIME_EXCLUDE - .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM - .ALIASES=EXCLUDE=_NOOP_MACRO PEERDIR=_NOOP_MACRO DEPENDENCY_MANAGEMENT=_NOOP_MACRO JAVA_RUNTIME_PEERDIR=PEERDIR JAVA_RUNTIME_EXCLUDE=EXCLUDE - .PEERDIRSELF=JAR_COMPILATION - - SET(MODULE_TYPE JAVA_PROGRAM) - } - module JAR_COMPILATION: JAR_LIBRARY { - .ALIASES=JAVA_RUNTIME_PEERDIR=_NOOP_MACRO JAVA_RUNTIME_EXCLUDE=_NOOP_MACRO - .FINAL_TARGET=no - SET(MODULE_TYPE JAVA_PROGRAM) - } -} - -# tag:java-specific -LINK_JAR_TEST=${hide:JAVA_FAKEID} ${WRITER_PY} --file ${BINDIR}/run-bf.txt -Q -m --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} --ya-end-command-file && ${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/run-bf.txt ${TARGET} ${kv;hide:"p JT"} -YMAKE_JAVA_TEST= -module _JAR_TEST: _COMPILABLE_JAR_BASE { - .FINAL_TARGET=yes - .CMD=LINK_JAR_TEST - .DEFAULT_NAME_GENERATOR=FullPath - CONSUME_NON_MANAGEABLE_PEERS=yes - - SET(MODULE_SUFFIX .test.cp.jar) - ENABLE(YMAKE_JAVA_TEST) - JAVA_TEST() - CHECK_PROVIDES() -} +@import "${CONF_ROOT}/conf/java.conf" # tag:python-specific tag:deprecated ### @usage: PY2_LIBRARY() # deprecated @@ -8554,952 +7668,7 @@ macro COLLECT_JINJA_TEMPLATES(VAR, DIR) { _GLOB($VAR ${DIR}/**/*.jinja ${DIR}/**/*.yaml) } -# 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"} -} +@import "${CONF_ROOT}/conf/go.conf" # Conflict between protobuf-java and protobuf-javalite ¯\_(ツ)_/¯ # both libraries are required by grpc |